Major update for v1 and tests
This commit is contained in:
19
src/main.jsx
19
src/main.jsx
@@ -3,20 +3,11 @@ import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import App from './App'
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.ready.then((registration) => {
|
||||
registration.addEventListener('updatefound', () => {
|
||||
const newWorker = registration.installing;
|
||||
newWorker.addEventListener('statechange', () => {
|
||||
if (newWorker.state === 'installed' && navigator.serviceWorker.controller) {
|
||||
window.dispatchEvent(new CustomEvent('swUpdated', { detail: newWorker }));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
// Service worker registration is handled inside <PWAInstall /> via the
|
||||
// `useRegisterSW` hook from `virtual:pwa-register/react`. We removed the
|
||||
// hand-rolled `navigator.serviceWorker.ready` listener that used to live here
|
||||
// because (a) it didn't actually register the SW — it just listened for updates
|
||||
// — and (b) it duplicated state the plugin already exposes via the hook.
|
||||
|
||||
createRoot(document.getElementById('root')).render(
|
||||
<StrictMode>
|
||||
|
||||
Reference in New Issue
Block a user