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.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: add skip cache requesting
Stevenb2ec0d121784
diff --git a/web/src/components/MemoEditor/RelationListView.tsx b/web/src/components/MemoEditor/RelationListView.tsxindex fb8e659ad..3974b4954 100644--- a/web/src/components/MemoEditor/RelationListView.tsx+++ b/web/src/components/MemoEditor/RelationListView.tsx@@ -19,7 +19,7 @@ const RelationListView = (props: Props) => {const requests = relationList.filter((relation) => relation.type === MemoRelation_Type.REFERENCE).map(async (relation) => {- return await memoStore.getOrFetchMemoById(relation.relatedMemoId);+ return await memoStore.getOrFetchMemoById(relation.relatedMemoId, { skipStore: true });});const list = await Promise.all(requests);setReferencingMemoList(list);diff --git a/web/src/components/MemoRelationListView.tsx b/web/src/components/MemoRelationListView.tsxindex c257eb52a..0a0de8a26 100644--- a/web/src/components/MemoRelationListView.tsx+++ b/web/src/components/MemoRelationListView.tsx@@ -22,13 +22,13 @@ const MemoRelationListView = (props: Props) => {const referencingMemoList = await Promise.all(relationList.filter((relation) => relation.memoId === memo.id && relation.relatedMemoId !== memo.id)- .map((relation) => memoStore.getOrFetchMemoById(relation.relatedMemoId))+ .map((relation) => memoStore.getOrFetchMemoById(relation.relatedMemoId, { skipStore: true })));setReferencingMemoList(referencingMemoList);const referencedMemoList = await Promise.all(relationList.filter((relation) => relation.memoId !== memo.id && relation.relatedMemoId === memo.id)- .map((relation) => memoStore.getOrFetchMemoById(relation.memoId))+ .map((relation) => memoStore.getOrFetchMemoById(relation.memoId, { skipStore: true })));setReferencedMemoList(referencedMemoList);})();diff --git a/web/src/components/MemoView.tsx b/web/src/components/MemoView.tsxindex ebf144882..5e37397b6 100644--- a/web/src/components/MemoView.tsx+++ b/web/src/components/MemoView.tsx@@ -102,7 +102,7 @@ const MemoView: React.FC<Props> = (props: Props) => {(relation) => relation.memoId === memo.id && relation.type === MemoRelation_Type.COMMENT)?.relatedMemoId;if (parentMemoId) {- memoStore.getOrFetchMemoById(parentMemoId).then((memo: Memo) => {+ memoStore.getOrFetchMemoById(parentMemoId, { skipStore: true }).then((memo: Memo) => {setParentMemo(memo);});}diff --git a/web/src/pages/MemoDetail.tsx b/web/src/pages/MemoDetail.tsxindex 2e6434c3c..df26dcf39 100644--- a/web/src/pages/MemoDetail.tsx+++ b/web/src/pages/MemoDetail.tsx@@ -106,7 +106,7 @@ const MemoDetail = () => {const handleCommentCreated = async (commentId: number) => {await memoStore.getOrFetchMemoById(commentId);- await memoStore.getOrFetchMemoById(memo.id, true /* skip cache */);+ await memoStore.getOrFetchMemoById(memo.id, { skipCache: true });};return (diff --git a/web/src/store/v1/memo.ts b/web/src/store/v1/memo.tsindex 7252073cb..93c5dfc84 100644--- a/web/src/store/v1/memo.ts+++ b/web/src/store/v1/memo.ts@@ -22,9 +22,9 @@ export const useMemoV1Store = create(});return memos;},- getOrFetchMemoById: async (id: number, skipCache = false) => {+ getOrFetchMemoById: async (id: number, options?: { skipCache?: boolean; skipStore?: boolean }) => {const memo = get().memoById.get(id);- if (memo && !skipCache) {+ if (memo && !options?.skipCache) {return memo;}@@ -35,10 +35,12 @@ export const useMemoV1Store = create(throw new Error("Memo not found");}- set((state) => {- state.memoById.set(id, res.memo as Memo);- return cloneDeep(state);- });+ if (!options?.skipStore) {+ set((state) => {+ state.memoById.set(id, res.memo as Memo);+ return cloneDeep(state);+ });+ }return res.memo;},getMemoById: (id: number) => {