From c712e87114d37059892dd3fc861588617aa13b07 Mon Sep 17 00:00:00 2001 From: EYHN Date: Thu, 14 Nov 2024 09:04:37 +0000 Subject: [PATCH] fix(core): warning when open center peek (#8819) --- .../common/infra/src/modules/doc/services/docs.ts | 12 ++++++++++++ .../block-suite-editor/blocksuite-editor.tsx | 4 ---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/common/infra/src/modules/doc/services/docs.ts b/packages/common/infra/src/modules/doc/services/docs.ts index 54951ad012..fbad956562 100644 --- a/packages/common/infra/src/modules/doc/services/docs.ts +++ b/packages/common/infra/src/modules/doc/services/docs.ts @@ -1,3 +1,4 @@ +import { DebugLogger } from '@affine/debug'; import { Unreachable } from '@affine/env/constant'; import { type AffineTextAttributes, @@ -16,6 +17,8 @@ import { DocScope } from '../scopes/doc'; import type { DocsStore } from '../stores/docs'; import { DocService } from './doc'; +const logger = new DebugLogger('DocsService'); + export class DocsService extends Service { list = this.framework.createEntity(DocRecordList); @@ -52,6 +55,15 @@ export class DocsService extends Service { record: docRecord, }); + try { + blockSuiteDoc.load(); + } catch (e) { + logger.error('Failed to load doc', { + docId, + error: e, + }); + } + const doc = docScope.get(DocService).doc; const { obj, release } = this.pool.put(docId, doc); diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx index 34317be3c3..504166e46e 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx @@ -32,10 +32,6 @@ export type EditorProps = { }; function usePageRoot(page: Doc) { - if (!page.ready) { - page.load(); - } - if (!page.root) { use( new Promise((resolve, reject) => {