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
|
@ -6,13 +6,30 @@
|
|||
import { lang } from '@@/js/config.js';
|
||||
|
||||
export async function initializeSw() {
|
||||
if (!('serviceWorker' in navigator)) return;
|
||||
if (!('serviceWorker' in navigator)) return;
|
||||
|
||||
navigator.serviceWorker.register('/sw.js', { scope: '/', type: 'classic' });
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
registration.active?.postMessage({
|
||||
msg: 'initialize',
|
||||
lang,
|
||||
});
|
||||
});
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,9 +134,9 @@ globalThis.addEventListener('notificationclick', (ev: ServiceWorkerGlobalScopeEv
|
|||
case 'showFollowRequests':
|
||||
client = await swos.openClient('push', '/my/follow-requests', loginId);
|
||||
break;
|
||||
case 'edited':
|
||||
if ('note' in data.body) client = await swos.openPost({ reply: data.body.note }, loginId);
|
||||
break;
|
||||
case 'edited':
|
||||
if ('note' in data.body) client = await swos.openPost({ reply: data.body.note }, loginId);
|
||||
break;
|
||||
default:
|
||||
switch (data.body.type) {
|
||||
case 'receiveFollowRequest':
|
||||
|
|
Loading…
Reference in a new issue