mirror of
https://github.com/toeverything/AFFiNE.git
synced 2025-01-04 10:23:12 +03:00
fix: a possible double connect issue (#3552)
This commit is contained in:
parent
8face25bdf
commit
6f488d963b
@ -111,8 +111,11 @@ export const createIndexedDBProvider = (
|
||||
let datasource: ReturnType<typeof createDatasource> | null = null;
|
||||
let provider: ReturnType<typeof createLazyProvider> | null = null;
|
||||
|
||||
return {
|
||||
const apis = {
|
||||
connect: () => {
|
||||
if (apis.connected) {
|
||||
apis.disconnect();
|
||||
}
|
||||
datasource = createDatasource({ dbName, mergeCount });
|
||||
provider = createLazyProvider(doc, datasource, { origin: 'idb' });
|
||||
provider.connect();
|
||||
@ -130,4 +133,6 @@ export const createIndexedDBProvider = (
|
||||
return provider?.connected || false;
|
||||
},
|
||||
};
|
||||
|
||||
return apis;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user