mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-24 16:26:44 -06:00
temp: try unregister sw
This commit is contained in:
parent
7864a631c4
commit
574798d019
2 changed files with 28 additions and 11 deletions
|
@ -8,11 +8,28 @@ import { lang } from '@@/js/config.js';
|
|||
export async function initializeSw() {
|
||||
if (!('serviceWorker' in navigator)) return;
|
||||
|
||||
navigator.serviceWorker.register('/sw.js', { scope: '/', type: 'classic' });
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
try {
|
||||
const registrations = await navigator.serviceWorker.getRegistrations();
|
||||
await Promise.all(
|
||||
registrations.map(registration => registration.unregister())
|
||||
);
|
||||
|
||||
console.info('Successfully unregistered old service worker(s)');
|
||||
|
||||
const registration = await navigator.serviceWorker.register('/sw.js', {
|
||||
scope: '/',
|
||||
type: 'classic'
|
||||
});
|
||||
|
||||
await navigator.serviceWorker.ready;
|
||||
|
||||
registration.active?.postMessage({
|
||||
msg: 'initialize',
|
||||
lang,
|
||||
});
|
||||
});
|
||||
|
||||
console.info('Successfully registered and initialized new service worker');
|
||||
} catch (error) {
|
||||
console.error('Service worker registration/initialization failed:', error);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue