From b6804a6201a6198cefdcfcfce7a6c38384eb060a Mon Sep 17 00:00:00 2001 From: tamaina Date: Thu, 5 Aug 2021 02:58:17 +0900 Subject: [PATCH] =?UTF-8?q?resolve=20https://github.com/misskey-dev/misske?= =?UTF-8?q?y/pull/7609/files/ba756204b77ce6e1189b8443e9641f2d02119621#diff?= =?UTF-8?q?-f565878e8202f0037b830c780b7c0932dc1bb5fd3d05ede14d72d10efbc374?= =?UTF-8?q?0c=20Firefox=E3=81=A7=E3=81=AE=E5=8B=95=E4=BD=9C=E3=82=92?= =?UTF-8?q?=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/client/account.ts | 22 +++++++++++----------- src/client/scripts/idb-proxy.ts | 8 ++------ yarn.lock | 15 +++++++++++---- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index c89fe96103..aceb5101d5 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,7 @@ "http-proxy-agent": "4.0.1", "http-signature": "1.3.5", "https-proxy-agent": "5.0.0", - "idb-keyval": "5.0.6", + "idb-keyval": "5.1.3", "insert-text-at-cursor": "0.3.0", "is-root": "2.1.0", "is-svg": "4.3.1", diff --git a/src/client/account.ts b/src/client/account.ts index f033bd3959..bee6d09ada 100644 --- a/src/client/account.ts +++ b/src/client/account.ts @@ -29,23 +29,23 @@ export async function signout() { //#endregion //#region Remove push notification registration - await navigator.serviceWorker.ready.then(async r => { - const push = await r.pushManager.getSubscription(); - if (!push) return; - return fetch(`${apiUrl}/sw/unregister`, { - method: 'POST', - body: JSON.stringify({ - i: $i.token, - endpoint: push.endpoint, - }), - }); + 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, + }), }); //#endregion document.cookie = `igi=; path=/`; if (accounts.length > 0) login(accounts[0].token); - else unisonReload(true); + else unisonReload(); } export async function getAccounts(): Promise<{ id: Account['id'], token: Account['token'] }[]> { diff --git a/src/client/scripts/idb-proxy.ts b/src/client/scripts/idb-proxy.ts index 6a3acc9894..23c7ee559d 100644 --- a/src/client/scripts/idb-proxy.ts +++ b/src/client/scripts/idb-proxy.ts @@ -4,6 +4,7 @@ import { get as iget, set as iset, del as idel, + createStore, } from 'idb-keyval'; const fallbackName = (key: string) => `idbfallback::${key}`; @@ -12,12 +13,7 @@ let idbAvailable = typeof window !== 'undefined' ? !!window.indexedDB : true; if (idbAvailable) { try { - const request = indexedDB.open('keyval-store'); - - await new Promise((res, rej) => { - request.onerror = (e) => rej(e); - request.onsuccess = (e) => res(e); - }); + await createStore('keyval-store', 'keyval') } catch (e) { console.error('idb open error', e); idbAvailable = false; diff --git a/yarn.lock b/yarn.lock index 60f6d11ba8..c1fef65d3f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5576,10 +5576,12 @@ icss-utils@^5.0.0, icss-utils@^5.1.0: resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-5.1.0.tgz#c6be6858abd013d768e98366ae47e25d5887b1ae" integrity sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA== -idb-keyval@5.0.6: - version "5.0.6" - resolved "https://registry.yarnpkg.com/idb-keyval/-/idb-keyval-5.0.6.tgz#62fe4a6703fb5ec86661f41330c94fda65e6d0e6" - integrity sha512-6lJuVbwyo82mKSH6Wq2eHkt9LcbwHAelMIcMe0tP4p20Pod7tTxq9zf0ge2n/YDfMOpDryerfmmYyuQiaFaKOg== +idb-keyval@5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/idb-keyval/-/idb-keyval-5.1.3.tgz#6ef5dff371897c23f144322dc6374eadd6a345d9" + integrity sha512-N9HbCK/FaXSRVI+k6Xq4QgWxbcZRUv+SfG1y7HJ28JdV8yEJu6k+C/YLea7npGckX2DQJeEVuMc4bKOBeU/2LQ== + dependencies: + safari-14-idb-fix "^1.0.4" ieee754@1.1.13, ieee754@^1.1.13, ieee754@^1.1.4: version "1.1.13" @@ -9740,6 +9742,11 @@ s-age@1.1.2: resolved "https://registry.yarnpkg.com/s-age/-/s-age-1.1.2.tgz#c0cf15233ccc93f41de92ea42c36d957977d1ea2" integrity sha512-aSN2TlF39WLoZA/6cgYSJZhKt63kJ4EaadejPWjWY9/h4rksIqvfWY3gfd+3uAegSM1IXsA9aWeEhJtkxkFQtA== +safari-14-idb-fix@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/safari-14-idb-fix/-/safari-14-idb-fix-1.0.4.tgz#5c68ba63e2a8ae0d89a0aa1e13fe89e3aef7da19" + integrity sha512-4+Y2baQdgJpzu84d0QjySl70Kyygzf0pepVg8NVg4NnQEPpfC91fAn0baNvtStlCjUUxxiu0BOMiafa98fRRuA== + safe-buffer@*: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"