feat(cache): implement centralized caching layer for improved performance and reduced API calls

feat(microsoft-integration): enhance inbox and events fetching with caching support
feat(auth): include theme and notification settings in user data retrieval
feat(profile): improve password visibility toggle functionality
feat(planner): optimize event synchronization with Outlook using caching
fix(notifications): update mail badge handling for mobile and desktop
This commit is contained in:
2026-09-10 15:19:46 +02:00
parent 5310b87fe5
commit 72ad1fb70e
15 changed files with 334 additions and 85 deletions
+29 -16
View File
@@ -425,15 +425,21 @@
if (res.ok) {
const data = await res.json();
if (data && data.success) {
// Update mail badge in navigatie
// Update mail badge in navigatie (desktop & mobiel)
const mailBadge = document.getElementById('navMailBadge');
if (mailBadge && typeof data.mail?.unread_count !== 'undefined') {
if (data.mail.unread_count > 0) {
mailBadge.innerText = data.mail.unread_count;
mailBadge.classList.remove('hidden');
} else {
mailBadge.classList.add('hidden');
}
const mailBadgeMobile = document.getElementById('navMailBadgeMobile');
if (typeof data.mail?.unread_count !== 'undefined') {
const count = parseInt(data.mail.unread_count, 10) || 0;
const badgeText = count > 99 ? '99+' : count;
[mailBadge, mailBadgeMobile].forEach(el => {
if (!el) return;
if (count > 0) {
el.innerText = badgeText;
el.classList.remove('hidden');
} else {
el.classList.add('hidden');
}
});
}
// E-mail melding
@@ -500,18 +506,25 @@
setInterval(refreshEvents, 60000);
// Evaluatie interval elke 15 seconden voor agenda popups
setInterval(evaluateEvents, 15000);
// Live sync interval elke 12 seconden voor instant mail, Jira & calendar updates
setInterval(checkLiveSync, 12000);
// Live sync interval elke 30 seconden voor mail, Jira & calendar updates
setInterval(checkLiveSync, 30000);
window.addEventListener('focus', () => {
checkLiveSync();
refreshEvents();
});
// Intelligente throttle voor window focus en tabwisseling (max 1x per 20s)
let lastFocusCheck = Date.now();
const throttledSync = () => {
const now = Date.now();
if (now - lastFocusCheck > 20000) {
lastFocusCheck = now;
checkLiveSync();
refreshEvents();
}
};
window.addEventListener('focus', throttledSync);
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
checkLiveSync();
refreshEvents();
throttledSync();
}
});