From 8ab9068d8e1a8362cbbb413d7abdc72233e9fa6e Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 21 Aug 2021 11:51:46 +0900 Subject: [PATCH] fix bug --- src/client/account.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/client/account.ts b/src/client/account.ts index cf52c4d82..7cd3d8cb8 100644 --- a/src/client/account.ts +++ b/src/client/account.ts @@ -29,16 +29,18 @@ export async function signout() { //#endregion //#region Remove push notification registration - const registration = await navigator.serviceWorker.ready; - const push = await registration.pushManager.getSubscription(); - if (!push) return; - await fetch(`${apiUrl}/sw/unregister`, { - method: 'POST', - body: JSON.stringify({ - i: $i.token, - endpoint: push.endpoint, - }), - }); + try { + const registration = await navigator.serviceWorker.ready; + const push = await registration.pushManager.getSubscription(); + if (!push) return; + await fetch(`${apiUrl}/sw/unregister`, { + method: 'POST', + body: JSON.stringify({ + i: $i.token, + endpoint: push.endpoint, + }), + }); + } catch (e) {} //#endregion document.cookie = `igi=; path=/`;