From a0b97f948cb9a0cd12dee74a048f9143083a1aa7 Mon Sep 17 00:00:00 2001 From: EYHN Date: Fri, 22 Mar 2024 10:06:37 +0000 Subject: [PATCH] fix(core): fix stuttering when change doc title (#6269) --- packages/common/infra/src/page/record-list.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/common/infra/src/page/record-list.ts b/packages/common/infra/src/page/record-list.ts index 5153548953..52c31c1958 100644 --- a/packages/common/infra/src/page/record-list.ts +++ b/packages/common/infra/src/page/record-list.ts @@ -1,4 +1,5 @@ -import { Observable } from 'rxjs'; +import { isEqual } from 'lodash-es'; +import { distinctUntilChanged, map, Observable } from 'rxjs'; import { LiveData } from '../livedata'; import { @@ -15,12 +16,10 @@ export class PageRecordList { ) {} public readonly records = LiveData.from( - new Observable(subscriber => { + new Observable(subscriber => { const emit = () => { subscriber.next( - this.workspace.docCollection.meta.docMetas.map( - v => new PageRecord(v.id, this.workspace, this.localState) - ) + this.workspace.docCollection.meta.docMetas.map(v => v.id) ); }; @@ -31,7 +30,12 @@ export class PageRecordList { return () => { dispose(); }; - }), + }).pipe( + distinctUntilChanged((p, c) => isEqual(p, c)), + map(ids => + ids.map(id => new PageRecord(id, this.workspace, this.localState)) + ) + ), [] );