Merge branch 'migrate-accounts-to-idb' into sw-notification-action

This commit is contained in:
tamaina 2021-07-27 01:49:49 +09:00
commit ea41ab3bba
1 changed files with 1 additions and 6 deletions

View File

@ -4,16 +4,12 @@ import {
get as iget, get as iget,
set as iset, set as iset,
del as idel, del as idel,
createStore
} from 'idb-keyval'; } from 'idb-keyval';
const fallbackName = (key: string) => `idbfallback::${key}`; const fallbackName = (key: string) => `idbfallback::${key}`;
let idbAvailable = typeof window !== 'undefined' ? !!window.indexedDB : true; let idbAvailable = typeof window !== 'undefined' ? !!window.indexedDB : true;
console.log(window.indexedDB);
console.log(idbAvailable);
if (idbAvailable) { if (idbAvailable) {
try { try {
const request = indexedDB.open('keyval-store'); const request = indexedDB.open('keyval-store');
@ -23,12 +19,11 @@ if (idbAvailable) {
request.onsuccess = (e) => res(e); request.onsuccess = (e) => res(e);
}); });
} catch (e) { } catch (e) {
console.log('catch', e) console.error('idb open error', e);
idbAvailable = false; idbAvailable = false;
} }
} }
console.log(idbAvailable);
if (!idbAvailable) 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) { export async function get(key: string) {