Commit edfbd6b0 authored by Steven's avatar Steven

fix(web): refresh sidebar tags when creating/updating memos

The sidebar tag list wasn't updating when users created new memos with tags
or modified existing memo tags. This was because useFilteredMemoStats hook
only refetched when filter/state/orderBy changed.

Now the hook observes memoStore.state.stateId, which changes whenever memos
are created, updated, or deleted. This triggers automatic refetch and the
sidebar updates immediately with the latest tag counts.

Fixes tag refresh issue in sidebar
parent cabd0d61
......@@ -2,6 +2,7 @@ import dayjs from "dayjs";
import { countBy } from "lodash-es";
import { useEffect, useState } from "react";
import { memoServiceClient } from "@/grpcweb";
import { memoStore } from "@/store";
import { State } from "@/types/proto/api/v1/common";
import type { StatisticsData } from "@/types/statistics";
......@@ -51,6 +52,8 @@ export const useFilteredMemoStats = (filter?: string, state: State = State.NORMA
tags: {},
loading: true,
});
// React to memo store changes (create, update, delete)
const memoStoreStateId = memoStore.state.stateId;
useEffect(() => {
const fetchMemosAndComputeStats = async () => {
......@@ -107,7 +110,7 @@ export const useFilteredMemoStats = (filter?: string, state: State = State.NORMA
};
fetchMemosAndComputeStats();
}, [filter, state, orderBy]);
}, [filter, state, orderBy, memoStoreStateId]);
return data;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment