fix(core): optimize performance when editing doc title (#7328)

This commit is contained in:
EYHN
2024-06-26 07:37:25 +00:00
parent ad746b6376
commit 092c639b0a
16 changed files with 136 additions and 142 deletions

View File

@@ -17,6 +17,7 @@ export class Doc extends Entity {
readonly meta$ = this.record.meta$;
readonly mode$ = this.record.mode$;
readonly title$ = this.record.title$;
readonly trash$ = this.record.trash$;
setMode(mode: DocMode) {
return this.record.setMode(mode);
@@ -33,4 +34,12 @@ export class Doc extends Entity {
observeMode() {
return this.record.observeMode();
}
moveToTrash() {
return this.record.moveToTrash();
}
restoreFromTrash() {
return this.record.restoreFromTrash();
}
}

View File

@@ -50,5 +50,14 @@ export class DocRecord extends Entity<{ id: string }> {
return this.docsStore.watchDocModeSetting(this.id);
}
moveToTrash() {
return this.setMeta({ trash: true });
}
restoreFromTrash() {
return this.setMeta({ trash: false });
}
title$ = this.meta$.map(meta => meta.title ?? '');
trash$ = this.meta$.map(meta => meta.trash ?? false);
}