diff --git a/backend/main.py b/backend/main.py index 0eb91e8..58b0679 100644 --- a/backend/main.py +++ b/backend/main.py @@ -327,7 +327,7 @@ MEDIA_DIR = os.getenv("MEDIA_DIR", "/data/media") os.makedirs(MEDIA_DIR, exist_ok=True) app.mount("/media", StaticFiles(directory=MEDIA_DIR), name="media") -APP_VER = "796" # muss mit APP_VER in app.js übereinstimmen +APP_VER = "797" # muss mit APP_VER in app.js übereinstimmen @app.get("/.well-known/assetlinks.json") async def assetlinks(): diff --git a/backend/static/index.html b/backend/static/index.html index a6c708a..46ced7b 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -628,20 +628,30 @@ window.addEventListener('load', () => { navigator.serviceWorker.register('/sw.js', { updateViaCache: 'none' }) .then(reg => { - // iOS PWA: Update sofort prüfen (Standalone-Modus prüft sonst nicht automatisch) reg.update(); + + // Primär: neuer SW hat aktiviert → sofort neu laden + reg.addEventListener('updatefound', () => { + const sw = reg.installing; + if (!sw) return; + sw.addEventListener('statechange', () => { + if (sw.state === 'activated') { + window.location.replace('/?_t=' + Date.now()); + } + }); + }); }) .catch(err => console.warn('SW Registration failed:', err)); }); - // iOS PWA: erneut prüfen wenn App aus dem Hintergrund kommt + // Backup: erneut prüfen wenn App aus dem Hintergrund kommt document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') { navigator.serviceWorker.getRegistration().then(reg => reg?.update()); } }); - // Wenn neuer SW die Kontrolle übernimmt → Seite neu laden + // Backup: controllerchange (falls updatefound nicht feuert) navigator.serviceWorker.addEventListener('controllerchange', () => { window.location.replace('/?_t=' + Date.now()); }); diff --git a/backend/static/js/app.js b/backend/static/js/app.js index b1783e7..8ebb039 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '796'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '797'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.5.0'; // ← semantische Version, wird bei make release gesetzt const IS_STAGING = location.hostname === 'staging.banyaro.app'; // Cache-Bust-Parameter nach Update-Reload sofort entfernen