Skip to content

Commit

Permalink
fix: optimize memoMap generation logic to ensure memoMap count matche…
Browse files Browse the repository at this point in the history
…s memos
  • Loading branch information
zjy4fun committed Dec 20, 2024
1 parent ce6ad40 commit dff1417
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions web/src/store/v1/memoMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<string, Memo>>(
(acc, memo) => ({
...acc,
[memo.name]: memo,
}),
{},
);
set({ stateId: uniqueId(), dataMapByName: memoMap });
return { memos, nextPageToken };
},
Expand Down

0 comments on commit dff1417

Please sign in to comment.