diff --git a/blocksuite/framework/store/src/model/store/store.ts b/blocksuite/framework/store/src/model/store/store.ts index d5df382f30..61135814b3 100644 --- a/blocksuite/framework/store/src/model/store/store.ts +++ b/blocksuite/framework/store/src/model/store/store.ts @@ -601,9 +601,7 @@ export class Store { this._yBlocks.observeDeep(this._handleYEvents); this._yBlocks.forEach((_, id) => { this._handleYBlockAdd(id, false); - }); - this._yBlocks.forEach((_, id) => { if (id in this._blocks.peek()) { return; } diff --git a/blocksuite/framework/store/src/test/test-doc.ts b/blocksuite/framework/store/src/test/test-doc.ts index ba9255def0..899a5729ce 100644 --- a/blocksuite/framework/store/src/test/test-doc.ts +++ b/blocksuite/framework/store/src/test/test-doc.ts @@ -1,4 +1,3 @@ -import { Subject } from 'rxjs'; import * as Y from 'yjs'; import type { YBlock } from '../model/block/types.js'; @@ -28,7 +27,6 @@ export class TestDoc implements Doc { }); this.rootDoc.getMap('spaces').set(this.id, subDoc); this._loaded = true; - this._onLoadSlot.next(); } else { this._loaded = false; this.rootDoc.on('subdocs', this._onSubdocEvent); @@ -39,8 +37,6 @@ export class TestDoc implements Doc { private _loaded!: boolean; - private readonly _onLoadSlot = new Subject(); - private readonly _onSubdocEvent = ({ loaded, }: { @@ -54,7 +50,6 @@ export class TestDoc implements Doc { } this.rootDoc.off('subdocs', this._onSubdocEvent); this._loaded = true; - this._onLoadSlot.next(); }; /** Indicate whether the block tree is ready */ @@ -132,7 +127,6 @@ export class TestDoc implements Doc { private _destroy() { this._ySpaceDoc.destroy(); - this._onLoadSlot.complete(); this._loaded = false; } diff --git a/packages/frontend/core/src/modules/workspace/impls/doc.ts b/packages/frontend/core/src/modules/workspace/impls/doc.ts index 5789a01748..c27bb8ab3b 100644 --- a/packages/frontend/core/src/modules/workspace/impls/doc.ts +++ b/packages/frontend/core/src/modules/workspace/impls/doc.ts @@ -9,7 +9,6 @@ import { type Workspace, type YBlock, } from '@blocksuite/affine/store'; -import { Subject } from 'rxjs'; import { Awareness } from 'y-protocols/awareness.js'; import * as Y from 'yjs'; @@ -24,7 +23,7 @@ export class DocImpl implements Doc { private readonly _storeMap = new Map(); - private readonly _initSubDoc = () => { + private readonly _initSpaceDoc = () => { { // This is a piece of old version compatible code. The old version relies on the subdoc instance on `spaces`. // So if there is no subdoc on spaces, we will create it. @@ -47,9 +46,6 @@ export class DocImpl implements Doc { private _loaded!: boolean; - // eslint-disable-next-line rxjs/finnish - private readonly _onLoadSlot = new Subject(); - /** Indicate whether the block tree is ready */ private _ready = false; @@ -104,7 +100,7 @@ export class DocImpl implements Doc { constructor({ id, collection, doc }: DocOptions) { this.id = id; this.rootDoc = doc; - this._ySpaceDoc = this._initSubDoc() as Y.Doc; + this._ySpaceDoc = this._initSpaceDoc() as Y.Doc; this.awarenessStore = new AwarenessStore(new Awareness(this._ySpaceDoc)); this._yBlocks = this._ySpaceDoc.getMap('blocks'); @@ -127,7 +123,6 @@ export class DocImpl implements Doc { private _destroy() { this.awarenessStore.destroy(); this._ySpaceDoc.destroy(); - this._onLoadSlot.unsubscribe(); this._loaded = false; }