Unregister existing service workers (#722)
In case some other app was served on the same domain which registered a service worker, this service worker was incorrectly used and never unregistered
This commit is contained in:
@@ -12,6 +12,18 @@ import { App } from '@/App';
|
|||||||
import '@/index.css';
|
import '@/index.css';
|
||||||
// roboto font
|
// roboto font
|
||||||
import '@fontsource/roboto';
|
import '@fontsource/roboto';
|
||||||
|
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
|
||||||
|
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker.ready.then((registration) => {
|
||||||
|
registration.unregister().catch(defaultPromiseErrorHandler('unregister service workers'));
|
||||||
|
if (caches) {
|
||||||
|
caches.keys().then(async (names) => {
|
||||||
|
await Promise.all(names.map((name) => caches.delete(name)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const container = document.getElementById('root');
|
const container = document.getElementById('root');
|
||||||
const root = createRoot(container!);
|
const root = createRoot(container!);
|
||||||
|
|||||||
Reference in New Issue
Block a user