From dff1417dcbf25d00bb5196b541f0d3694771ae25 Mon Sep 17 00:00:00 2001 From: zjy4fun Date: Fri, 20 Dec 2024 11:21:34 +0800 Subject: [PATCH] fix: optimize memoMap generation logic to ensure memoMap count matches memos --- web/src/store/v1/memoMetadata.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/web/src/store/v1/memoMetadata.ts b/web/src/store/v1/memoMetadata.ts index 2c92f3852d85a..fd8dd5897ca7f 100644 --- a/web/src/store/v1/memoMetadata.ts +++ b/web/src/store/v1/memoMetadata.ts @@ -41,10 +41,13 @@ export const useMemoMetadataStore = create( view: MemoView.MEMO_VIEW_METADATA_ONLY, pageSize: DEFAULT_MEMO_PAGE_SIZE, }); - const memoMap = { ...get().dataMapByName }; - for (const memo of memos) { - memoMap[memo.name] = memo; - } + const memoMap = memos.reduce>( + (acc, memo) => ({ + ...acc, + [memo.name]: memo, + }), + {}, + ); set({ stateId: uniqueId(), dataMapByName: memoMap }); return { memos, nextPageToken }; },