fix: watch list do not update when creating

This commit is contained in:
jialin
2026-06-10 15:37:27 +08:00
committed by jialin
parent 6f96260993
commit 698090b17a
3 changed files with 11 additions and 17 deletions
+4
View File
@@ -89,6 +89,10 @@ export function useUpdateChunkedList(options: {
...cacheDataListRef.current
].slice(0, limit);
options.setDataList?.([...cacheDataListRef.current], {
createdIds: newDataList.map((item) => item.id)
});
options.onCreate?.(latestCreateList);
}
+3 -3
View File
@@ -55,7 +55,7 @@ export default function useWatchList<T = Record<string, any>>(API: string) {
cacheWatchDataListRef.current = cacheWatchDataListRef.current.filter(
(item) => item.id !== id
);
setWatchDataList(cacheWatchDataListRef.current);
setWatchDataList(() => cacheWatchDataListRef.current);
};
const getAllDataList = useMemoizedFn(async () => {
@@ -63,8 +63,7 @@ export default function useWatchList<T = Record<string, any>>(API: string) {
listRequestTokenRef.current?.cancel?.();
listRequestTokenRef.current = createAxiosToken();
const params = {
page: 1,
perPage: 100
page: -1
};
const res: any = await queryAllDataList(params, {
token: listRequestTokenRef.current.token
@@ -86,6 +85,7 @@ export default function useWatchList<T = Record<string, any>>(API: string) {
return {
watchDataList,
setWatchDataList,
deleteItemFromCache: handleDeleteItemFromCache
};
}