diff --git a/public/pages/dashboard.js b/public/pages/dashboard.js index ac055b8..2de3708 100644 --- a/public/pages/dashboard.js +++ b/public/pages/dashboard.js @@ -655,7 +655,7 @@ export async function render(container, { user }) { weather = weatherRes.data ?? null; widgetConfig = prefsRes.data?.dashboard_widgets ?? DEFAULT_WIDGET_CONFIG; } catch (err) { - console.error('[Dashboard] Ladefehler:', err.message); + console.error('[Dashboard] Ladefehler:', err.message, 'Status:', err.status ?? 'network'); window.oikos?.showToast(t('dashboard.loadError'), 'warning'); } diff --git a/public/router.js b/public/router.js index d1d1ce7..4e97e0b 100644 --- a/public/router.js +++ b/public/router.js @@ -115,6 +115,9 @@ async function importPage(pagePath) { let currentUser = null; let currentPath = null; let isNavigating = false; +// Gesetzt wenn auth:expired waehrend einer laufenden Navigation feuert. +// Die Weiterleitung zu /login wird nach Abschluss der Navigation nachgeholt. +let _pendingLoginRedirect = false; // -------------------------------------------------------- // Router @@ -189,6 +192,13 @@ async function navigate(path, userOrPushState = true, pushState = true) { updateThemeColorForRoute(route); } finally { isNavigating = false; + // auth:expired kann waehrend einer Navigation gefeuert haben (z.B. wenn ein + // paralleler API-Call 401 zurueckgab). Jetzt wo die Navigation abgeschlossen + // ist, holen wir die Login-Weiterleitung nach. + if (_pendingLoginRedirect) { + _pendingLoginRedirect = false; + navigate('/login'); + } } } @@ -511,7 +521,13 @@ window.addEventListener('popstate', (e) => { window.addEventListener('auth:expired', () => { currentUser = null; stopReminders(); - navigate('/login'); + if (isNavigating) { + // navigate('/login') kann nicht sofort aufgerufen werden - wird im finally-Block + // der laufenden Navigation nachgeholt. + _pendingLoginRedirect = true; + } else { + navigate('/login'); + } }); // Sprache geƤndert: Navigation neu rendern damit Labels aktualisiert werden diff --git a/public/sw.js b/public/sw.js index ab80dd0..3c4d3f1 100644 --- a/public/sw.js +++ b/public/sw.js @@ -12,8 +12,8 @@ * API: Immer Netzwerk (kein Caching von Nutzerdaten) */ -const SHELL_CACHE = 'oikos-shell-v33'; -const PAGES_CACHE = 'oikos-pages-v28'; +const SHELL_CACHE = 'oikos-shell-v34'; +const PAGES_CACHE = 'oikos-pages-v29'; const ASSETS_CACHE = 'oikos-assets-v27'; const ALL_CACHES = [SHELL_CACHE, PAGES_CACHE, ASSETS_CACHE];