({ link: 0, taskList: 0, code: 0, incompleteTasks: 0 });
- const days = Math.ceil((Date.now() - user.createTime!.getTime()) / 86400000);
- const memos = Object.values(memoStore.getState().memoMapByName);
+ const days = Math.ceil((Date.now() - currentUser.createTime!.getTime()) / 86400000);
const filter = filterStore.state;
useAsyncEffect(async () => {
@@ -56,7 +51,7 @@ const UserStatisticsView = (props: Props) => {
setMemoStats(memoStats);
setMemoAmount(properties.length);
setIsRequesting(false);
- }, [memos.length, user.name]);
+ }, [memoStore.stateId]);
const handleRebuildMemoTags = async () => {
await memoServiceClient.rebuildMemoProperty({
@@ -117,20 +112,24 @@ const UserStatisticsView = (props: Props) => {
onClick={() => filterStore.setMemoPropertyFilter({ hasTaskList: !filter.memoPropertyFilter?.hasTaskList })}
>
-
+ {memoStats.incompleteTasks > 0 ? (
+
+ ) : (
+
+ )}
{t("memo.to-do")}
- {memoStats.incompleteTasks > 0 && (
- <>
-
- {memoStats.taskList - memoStats.incompleteTasks}
-
- /
- >
- )}
-
+ {memoStats.incompleteTasks > 0 ? (
+
+
+ {memoStats.taskList - memoStats.incompleteTasks}
+ /
+ {memoStats.taskList}
+
+
+ ) : (
{memoStats.taskList}
-
+ )}
;
}
const getDefaultState = (): State => ({
+ stateId: uniqueId(),
memoMapByName: {},
});
@@ -21,7 +26,7 @@ export const useMemoStore = create(
for (const memo of memos) {
memoMap[memo.name] = memo;
}
- set({ memoMapByName: memoMap });
+ set({ stateId: uniqueId(), memoMapByName: memoMap });
return { memos, nextPageToken };
},
getOrFetchMemoByName: async (name: string, options?: { skipCache?: boolean; skipStore?: boolean }) => {
@@ -36,7 +41,7 @@ export const useMemoStore = create(
});
if (!options?.skipStore) {
memoMap[name] = memo;
- set({ memoMapByName: memoMap });
+ set({ stateId: uniqueId(), memoMapByName: memoMap });
}
return memo;
},
@@ -51,7 +56,7 @@ export const useMemoStore = create(
for (const memo of memos) {
memoMap[memo.name] = memo;
}
- set({ memoMapByName: memoMap });
+ set({ stateId: uniqueId(), memoMapByName: memoMap });
return memos;
},
getMemoByUid: (uid: string) => {
@@ -62,7 +67,7 @@ export const useMemoStore = create(
const memo = await memoServiceClient.createMemo(request);
const memoMap = get().memoMapByName;
memoMap[memo.name] = memo;
- set({ memoMapByName: memoMap });
+ set({ stateId: uniqueId(), memoMapByName: memoMap });
return memo;
},
updateMemo: async (update: Partial, updateMask: string[]) => {
@@ -73,7 +78,7 @@ export const useMemoStore = create(
const memoMap = get().memoMapByName;
memoMap[memo.name] = memo;
- set({ memoMapByName: memoMap });
+ set({ stateId: uniqueId(), memoMapByName: memoMap });
return memo;
},
deleteMemo: async (name: string) => {
@@ -83,7 +88,7 @@ export const useMemoStore = create(
const memoMap = get().memoMapByName;
delete memoMap[name];
- set({ memoMapByName: memoMap });
+ set({ stateId: uniqueId(), memoMapByName: memoMap });
},
})),
);
@@ -93,7 +98,7 @@ export const useMemoList = () => {
const memos = Object.values(memoStore.getState().memoMapByName);
const reset = () => {
- memoStore.setState({ memoMapByName: {} });
+ memoStore.setState({ stateId: uniqueId(), memoMapByName: {} });
};
const size = () => {