refactor: remove y-indexeddb (#1771)

This commit is contained in:
Himself65
2023-04-02 02:57:50 -05:00
committed by GitHub
parent f5574c68fe
commit ed8f07f102
12 changed files with 918 additions and 35 deletions

View File

@@ -1,6 +1,6 @@
import { nanoid, Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
import { createIndexedDBProvider } from '@toeverything/y-indexeddb';
import { createJSONStorage } from 'jotai/utils';
import { IndexeddbPersistence } from 'y-indexeddb';
import { z } from 'zod';
import { createLocalProviders } from '../providers';
@@ -47,9 +47,10 @@ export const CRUD: WorkspaceCRUD<WorkspaceFlavour.LOCAL> = {
(_: string) => undefined
);
BlockSuiteWorkspace.Y.applyUpdateV2(blockSuiteWorkspace.doc, binary);
const persistence = new IndexeddbPersistence(id, blockSuiteWorkspace.doc);
const persistence = createIndexedDBProvider(id, blockSuiteWorkspace.doc);
persistence.connect();
await persistence.whenSynced.then(() => {
persistence.destroy();
persistence.disconnect();
});
storage.setItem(kStoreKey, [...data, id]);
console.log('create', id, storage.getItem(kStoreKey));