From 8141ef1f91269720ac90a7c49a4b725baf5b4aca Mon Sep 17 00:00:00 2001 From: DiamondThree <857159145@qq.com> Date: Thu, 2 Feb 2023 19:17:07 +0800 Subject: [PATCH] fix: delete db cause page reload --- packages/data-center/src/provider/affine/idb-kv.ts | 7 +++---- packages/data-center/src/provider/affine/utils.ts | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/data-center/src/provider/affine/idb-kv.ts b/packages/data-center/src/provider/affine/idb-kv.ts index 72f854dd82..37dcbe64df 100644 --- a/packages/data-center/src/provider/affine/idb-kv.ts +++ b/packages/data-center/src/provider/affine/idb-kv.ts @@ -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 = { keys: () => Promise; - deleteDB: () => Promise; + clear: () => Promise; setMany: (entries: [string, T][]) => Promise; getMany: (keys: string[]) => Promise; }; @@ -16,7 +15,7 @@ export function getDatabase( 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), }; diff --git a/packages/data-center/src/provider/affine/utils.ts b/packages/data-center/src/provider/affine/utils.ts index 6e4387f240..54931fe9de 100644 --- a/packages/data-center/src/provider/affine/utils.ts +++ b/packages/data-center/src/provider/affine/utils.ts @@ -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(); };