feat: improve PWA auth robustness and session management
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user