From f6d8867df2b4db81cb8cca33aa1e54e4c72cae31 Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 31 Aug 2021 20:56:01 +0900 Subject: [PATCH] fix logout behavior when there is no push subscription --- src/client/account.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/client/account.ts b/src/client/account.ts index 69755819fe..97085aca47 100644 --- a/src/client/account.ts +++ b/src/client/account.ts @@ -35,14 +35,15 @@ export async function signout() { 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, - }), - }); + if (push) { + await fetch(`${apiUrl}/sw/unregister`, { + method: 'POST', + body: JSON.stringify({ + i: $i.token, + endpoint: push.endpoint, + }), + }); + } } catch (e) {} //#endregion