From 9f1edb4049730750ef77b2d6284bad58a679eaa1 Mon Sep 17 00:00:00 2001 From: fundon Date: Fri, 13 Sep 2024 12:52:49 +0000 Subject: [PATCH] refactor(blocks): improve state initialization in EmbedLinkedDocBlockComponent (#8354) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes [BS-1417](https://linear.app/affine-design/issue/BS-1417/在-shared-doc-里,card-view-或者-embed-view-的-linked-doc-均无法正常显示) --- .../embed-linked-doc-block.ts | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/blocks/src/embed-linked-doc-block/embed-linked-doc-block.ts b/packages/blocks/src/embed-linked-doc-block/embed-linked-doc-block.ts index f40ac1b7bbe5..8466dd68f18c 100644 --- a/packages/blocks/src/embed-linked-doc-block/embed-linked-doc-block.ts +++ b/packages/blocks/src/embed-linked-doc-block/embed-linked-doc-block.ts @@ -37,10 +37,21 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent { - this._loading = true; - this.isError = false; - this.isNoteContentEmpty = true; - this.isBannerEmpty = true; + const { + loading = true, + isError = false, + isBannerEmpty = true, + isNoteContentEmpty = true, + } = this.resetState(); + + this._loading = loading; + this.isError = isError; + this.isBannerEmpty = isBannerEmpty; + this.isNoteContentEmpty = isNoteContentEmpty; + + if (!this._loading) { + return; + } const linkedDoc = this.linkedDoc; if (!linkedDoc) { @@ -445,6 +456,15 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent