From 59645e620a2d2ef928b4f47e0e5c4ccdadbe7211 Mon Sep 17 00:00:00 2001 From: fyears Date: Sun, 14 Nov 2021 20:51:29 +0800 Subject: [PATCH] manually delete indexeddb --- src/localdb.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/localdb.ts b/src/localdb.ts index d929997..0e87156 100644 --- a/src/localdb.ts +++ b/src/localdb.ts @@ -83,10 +83,21 @@ export const prepareDBs = async () => { }; export const destroyDBs = async () => { - await localforage.dropInstance({ - name: DEFAULT_DB_NAME, - }); - console.log("db deleted"); + // await localforage.dropInstance({ + // name: DEFAULT_DB_NAME, + // }); + // console.log("db deleted"); + const req = indexedDB.deleteDatabase(DEFAULT_DB_NAME); + req.onsuccess = (event) => { + console.log("db deleted"); + }; + req.onblocked = (event) => { + console.warn("trying to delete db but it was blocked"); + }; + req.onerror = (event) => { + console.error("tried to delete db but something bad!"); + console.error(event); + }; }; const migrateDBs = async (db: InternalDBs, oldVer: number, newVer: number) => {