From 106a0226321533fd131a9bc9193bd3128b417828 Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 31 Aug 2021 21:42:13 +0900 Subject: [PATCH] clean up service worker registration --- src/client/account.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/client/account.ts b/src/client/account.ts index efe9f19527..50eb7ecba3 100644 --- a/src/client/account.ts +++ b/src/client/account.ts @@ -31,7 +31,7 @@ export async function signout() { else await del('accounts'); //#endregion - //#region Remove push notification registration + //#region Remove service worker registration try { if (navigator.serviceWorker.controller) { const registration = await navigator.serviceWorker.ready; @@ -46,6 +46,13 @@ export async function signout() { }); } } + + if (accounts.length === 0) { + await navigator.serviceWorker.getRegistrations() + .then(registrations => { + return Promise.all(registrations.map(registration => registration.unregister())); + }) + } } catch (e) {} //#endregion