feat: register service worker in index.html so PWA cache busting works
This commit is contained in:
@@ -7030,6 +7030,22 @@
|
|||||||
};
|
};
|
||||||
return map[name] || name;
|
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', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
initAuth();
|
initAuth();
|
||||||
initGPS();
|
initGPS();
|
||||||
|
|||||||
Reference in New Issue
Block a user