fix: delete db cause page reload

This commit is contained in:
DiamondThree 2023-02-02 19:17:07 +08:00
parent fca165c672
commit 8141ef1f91
2 changed files with 5 additions and 7 deletions

View File

@ -1,9 +1,8 @@
import { createStore, keys, setMany, getMany } from 'idb-keyval';
import * as idb from 'lib0/indexeddb.js';
import { createStore, keys, setMany, getMany, clear } from 'idb-keyval';
type IDBInstance<T = ArrayBufferLike> = {
keys: () => Promise<string[]>;
deleteDB: () => Promise<void>;
clear: () => Promise<void>;
setMany: (entries: [string, T][]) => Promise<void>;
getMany: (keys: string[]) => Promise<T[]>;
};
@ -16,7 +15,7 @@ export function getDatabase<T = ArrayBufferLike>(
const db = createStore(name, type);
return {
keys: () => keys(db),
deleteDB: () => idb.deleteDB(name),
clear: () => clear(db),
setMany: entries => setMany(entries, db),
getMany: keys => getMany(keys, db),
};

View File

@ -82,7 +82,6 @@ export const migrateBlobDB = async (
return [id, { id, blob }] as [string, PendingTask];
});
await newPendingDB.setMany(pendingEntries);
// FIXME: delete old db
// await oldDB.deleteDB();
// await oldPendingDB.deleteDB();
await oldDB.clear();
await oldPendingDB.clear();
};