feat: improve PWA auth robustness and session management

This commit is contained in:
2025-12-18 21:27:00 +01:00
parent 409e78f2f4
commit 087292f65d
3 changed files with 41 additions and 15 deletions

View File

@@ -10,6 +10,21 @@ export default function PWARegistration() {
.register('/sw.js')
.then((registration) => {
console.log('SW registered: ', registration);
// Check for updates
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) return;
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
console.log('[SW] New content is available; please refresh.');
} else {
console.log('[SW] Content is cached for offline use.');
}
}
};
};
})
.catch((registrationError) => {
console.log('SW registration failed: ', registrationError);