mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
fix(editor): add trash state for linked-doc and synced-doc appearance (#13767)
This PR updates the appearance of `embed-linked-doc-block` and `embed-synced-doc-block` to reflect the trashed state of their linked documents. Previously, these blocks showed no visual difference whether the linked document was trashed or not, despite the existing of codes for deletion-related appearance. This change ensures that the deletion appearance is properly displayed.  <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Documents now support trash state tracking for improved deletion management * **Bug Fixes** * Improved synchronization and refresh of embedded documents when document states change * Enhanced handling of trashed documents in embedded content <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -323,7 +323,8 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
|||||||
|
|
||||||
private readonly _renderEmbedView = () => {
|
private readonly _renderEmbedView = () => {
|
||||||
const linkedDoc = this.linkedDoc;
|
const linkedDoc = this.linkedDoc;
|
||||||
const isDeleted = !linkedDoc;
|
const trash = linkedDoc?.meta?.trash;
|
||||||
|
const isDeleted = trash || !linkedDoc;
|
||||||
const isLoading = this._loading;
|
const isLoading = this._loading;
|
||||||
const isError = this.isError;
|
const isError = this.isError;
|
||||||
const isEmpty = this._isDocEmpty() && this.isBannerEmpty;
|
const isEmpty = this._isDocEmpty() && this.isBannerEmpty;
|
||||||
@@ -521,11 +522,6 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
|||||||
);
|
);
|
||||||
|
|
||||||
this._setDocUpdatedAt();
|
this._setDocUpdatedAt();
|
||||||
this.disposables.add(
|
|
||||||
this.store.workspace.slots.docListUpdated.subscribe(() => {
|
|
||||||
this._setDocUpdatedAt();
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this._referenceToNode) {
|
if (this._referenceToNode) {
|
||||||
this._linkedDocMode = this.model.props.params?.mode ?? 'page';
|
this._linkedDocMode = this.model.props.params?.mode ?? 'page';
|
||||||
@@ -554,6 +550,13 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.disposables.add(
|
||||||
|
this.store.workspace.slots.docListUpdated.subscribe(() => {
|
||||||
|
this._setDocUpdatedAt();
|
||||||
|
this.refreshData();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
this._trackCitationDeleteEvent();
|
this._trackCitationDeleteEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -357,10 +357,14 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
|
|||||||
};
|
};
|
||||||
|
|
||||||
refreshData = () => {
|
refreshData = () => {
|
||||||
this._load().catch(e => {
|
this._load()
|
||||||
console.error(e);
|
.then(() => {
|
||||||
this._error = true;
|
this._isEmptySyncedDoc = isEmptyDoc(this.syncedDoc, this.editorMode);
|
||||||
});
|
})
|
||||||
|
.catch(e => {
|
||||||
|
console.error(e);
|
||||||
|
this._error = true;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
title$ = computed(() => {
|
title$ = computed(() => {
|
||||||
@@ -445,7 +449,8 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
|
|||||||
this._cycle = false;
|
this._cycle = false;
|
||||||
|
|
||||||
const syncedDoc = this.syncedDoc;
|
const syncedDoc = this.syncedDoc;
|
||||||
if (!syncedDoc) {
|
const trash = syncedDoc?.meta?.trash;
|
||||||
|
if (trash || !syncedDoc) {
|
||||||
this._deleted = true;
|
this._deleted = true;
|
||||||
this._loading = false;
|
this._loading = false;
|
||||||
return;
|
return;
|
||||||
@@ -521,6 +526,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
|
|||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.store.workspace.slots.docListUpdated.subscribe(() => {
|
this.store.workspace.slots.docListUpdated.subscribe(() => {
|
||||||
this._setDocUpdatedAt();
|
this._setDocUpdatedAt();
|
||||||
|
this.refreshData();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export interface DocMeta {
|
|||||||
createDate: number;
|
createDate: number;
|
||||||
updatedDate?: number;
|
updatedDate?: number;
|
||||||
favorite?: boolean;
|
favorite?: boolean;
|
||||||
|
trash?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WorkspaceMeta {
|
export interface WorkspaceMeta {
|
||||||
|
|||||||
Reference in New Issue
Block a user