mirror of
https://github.com/toeverything/AFFiNE.git
synced 2025-01-01 16:53:04 +03:00
Merge pull request #771 from toeverything/fix-deletedb-error
fix: delete db cause page reload
This commit is contained in:
commit
5af42d3784
@ -1,8 +1,9 @@
|
|||||||
import { createStore, keys, setMany, getMany } from 'idb-keyval';
|
import { createStore, keys, setMany, getMany, clear } from 'idb-keyval';
|
||||||
import * as idb from 'lib0/indexeddb.js';
|
import * as idb from 'lib0/indexeddb.js';
|
||||||
|
|
||||||
type IDBInstance<T = ArrayBufferLike> = {
|
type IDBInstance<T = ArrayBufferLike> = {
|
||||||
keys: () => Promise<string[]>;
|
keys: () => Promise<string[]>;
|
||||||
|
clear: () => Promise<void>;
|
||||||
deleteDB: () => Promise<void>;
|
deleteDB: () => Promise<void>;
|
||||||
setMany: (entries: [string, T][]) => Promise<void>;
|
setMany: (entries: [string, T][]) => Promise<void>;
|
||||||
getMany: (keys: string[]) => Promise<T[]>;
|
getMany: (keys: string[]) => Promise<T[]>;
|
||||||
@ -16,6 +17,7 @@ export function getDatabase<T = ArrayBufferLike>(
|
|||||||
const db = createStore(name, type);
|
const db = createStore(name, type);
|
||||||
return {
|
return {
|
||||||
keys: () => keys(db),
|
keys: () => keys(db),
|
||||||
|
clear: () => clear(db),
|
||||||
deleteDB: () => idb.deleteDB(name),
|
deleteDB: () => idb.deleteDB(name),
|
||||||
setMany: entries => setMany(entries, db),
|
setMany: entries => setMany(entries, db),
|
||||||
getMany: keys => getMany(keys, db),
|
getMany: keys => getMany(keys, db),
|
||||||
|
@ -83,6 +83,6 @@ export const migrateBlobDB = async (
|
|||||||
});
|
});
|
||||||
await newPendingDB.setMany(pendingEntries);
|
await newPendingDB.setMany(pendingEntries);
|
||||||
|
|
||||||
await oldDB.deleteDB();
|
await oldDB.clear();
|
||||||
await oldPendingDB.deleteDB();
|
await oldPendingDB.clear();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user