summaryrefslogtreecommitdiff
path: root/packages/client/src/scripts/idb-proxy.ts
diff options
context:
space:
mode:
authorJohann150 <johann.galle@protonmail.com>2022-07-13 14:17:19 +0200
committerGitHub <noreply@github.com>2022-07-13 21:17:19 +0900
commitee9bb8286e347aac1c769bdd3c65a0bccf610a73 (patch)
tree7df66c9f572032eecbffd0d8e18e2bf2c0fdd247 /packages/client/src/scripts/idb-proxy.ts
parentfix(sw, notification): Don't issue an event if there is no affect (#8979) (diff)
downloadsharkey-ee9bb8286e347aac1c769bdd3c65a0bccf610a73.tar.gz
sharkey-ee9bb8286e347aac1c769bdd3c65a0bccf610a73.tar.bz2
sharkey-ee9bb8286e347aac1c769bdd3c65a0bccf610a73.zip
fix: add `es2017` build target (#8931)
* remove top level awaits * add es2017 target * refactor: use setup and ref sugar
Diffstat (limited to 'packages/client/src/scripts/idb-proxy.ts')
-rw-r--r--packages/client/src/scripts/idb-proxy.ts11
1 files changed, 5 insertions, 6 deletions
diff --git a/packages/client/src/scripts/idb-proxy.ts b/packages/client/src/scripts/idb-proxy.ts
index d462a0d7ce..77bb84463c 100644
--- a/packages/client/src/scripts/idb-proxy.ts
+++ b/packages/client/src/scripts/idb-proxy.ts
@@ -11,16 +11,15 @@ const fallbackName = (key: string) => `idbfallback::${key}`;
let idbAvailable = typeof window !== 'undefined' ? !!window.indexedDB : true;
if (idbAvailable) {
- try {
- await iset('idb-test', 'test');
- } catch (err) {
+ iset('idb-test', 'test').catch(err => {
console.error('idb error', err);
+ console.error('indexedDB is unavailable. It will use localStorage.');
idbAvailable = false;
- }
+ });
+} else {
+ console.error('indexedDB is unavailable. It will use localStorage.');
}
-if (!idbAvailable) console.error('indexedDB is unavailable. It will use localStorage.');
-
export async function get(key: string) {
if (idbAvailable) return iget(key);
return JSON.parse(localStorage.getItem(fallbackName(key)));