Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: optimize memoMap generation logic to ensure memoMap count matche… (#4214)

zjy4funf15346e615fd
diff --git a/web/src/store/v1/memoMetadata.ts b/web/src/store/v1/memoMetadata.ts
index 2c92f3852..fd8dd5897 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<Record<string, Memo>>(
+ (acc, memo) => ({
+ ...acc,
+ [memo.name]: memo,
+ }),
+ {},
+ );
set({ stateId: uniqueId(), dataMapByName: memoMap });
return { memos, nextPageToken };
},