From dd63dc97d5c87fdc3bcc046b086b8eb7d0f9b297 Mon Sep 17 00:00:00 2001 From: Shawn Date: Tue, 2 Jun 2026 18:34:01 -0400 Subject: [PATCH] feat: register service worker in index.html so PWA cache busting works --- static/index.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/static/index.html b/static/index.html index 2e3b2fb..02ff26b 100644 --- a/static/index.html +++ b/static/index.html @@ -7030,6 +7030,22 @@ }; return map[name] || name; } + // ── Register service worker for PWA caching ────────────────────── + if ('serviceWorker' in navigator) { + navigator.serviceWorker.register('/sw.js').then(reg => { + reg.onupdatefound = () => { + const installing = reg.installing; + if (installing) { + installing.onstatechange = () => { + if (installing.state === 'installed' && navigator.serviceWorker.controller) { + console.log('PWA update available — reload to activate'); + } + }; + } + }; + }).catch(e => console.warn('SW registration failed:', e)); + } + document.addEventListener('DOMContentLoaded', () => { initAuth(); initGPS();