fix: worker list params do not update
This commit is contained in:
@@ -89,6 +89,7 @@ export default function useTableFetch<T>(
|
|||||||
sort_by: '',
|
sort_by: '',
|
||||||
...defaultQueryParams
|
...defaultQueryParams
|
||||||
});
|
});
|
||||||
|
const queryParamsRef = useRef(queryParams);
|
||||||
|
|
||||||
// for recognize the current watch trigger time, so that we can ignore the previous events
|
// for recognize the current watch trigger time, so that we can ignore the previous events
|
||||||
const triggerAtRef = useRef<number>(0);
|
const triggerAtRef = useRef<number>(0);
|
||||||
@@ -97,6 +98,10 @@ export default function useTableFetch<T>(
|
|||||||
|
|
||||||
const debounceSetExtraStatus = _.debounce(setExtraStatus, 3000);
|
const debounceSetExtraStatus = _.debounce(setExtraStatus, 3000);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
queryParamsRef.current = queryParams;
|
||||||
|
}, [queryParams]);
|
||||||
|
|
||||||
const fetchData = async (
|
const fetchData = async (
|
||||||
externalParams?: { query: Record<string, any>; loadmore?: boolean },
|
externalParams?: { query: Record<string, any>; loadmore?: boolean },
|
||||||
polling = false
|
polling = false
|
||||||
@@ -187,9 +192,21 @@ export default function useTableFetch<T>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-ignore for watch mode
|
// @ts-ignore for watch mode
|
||||||
const debounceFetchData = _.debounce(() => fetchData({}, true), 1000);
|
const debounceFetchData = _.debounce(
|
||||||
|
() =>
|
||||||
|
fetchData(
|
||||||
|
{
|
||||||
|
query: {
|
||||||
|
...queryParamsRef.current
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true
|
||||||
|
),
|
||||||
|
1000
|
||||||
|
);
|
||||||
|
|
||||||
const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({
|
const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({
|
||||||
|
limit: queryParams.perPage,
|
||||||
events: events,
|
events: events,
|
||||||
dataList: dataSource.dataList,
|
dataList: dataSource.dataList,
|
||||||
triggerAt: updateManually ? triggerAtRef : undefined,
|
triggerAt: updateManually ? triggerAtRef : undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user