fix: model list watch data

This commit is contained in:
jialin
2024-07-15 08:21:06 +08:00
parent 0a0b96735c
commit ec28523daa
17 changed files with 119 additions and 61 deletions
+7 -2
View File
@@ -30,7 +30,8 @@ const Models: React.FC = () => {
dataSourceRef.current = dataSource;
const { updateChunkedList } = useUpdateChunkedList({
const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({
dataList: dataSource,
setDataList: setDataSource
});
@@ -46,7 +47,9 @@ const Models: React.FC = () => {
cancelToken: axiosToken.token
});
console.log('res=======', res);
setDataSource(res.items);
if (!firstLoad) {
setDataSource(res.items);
}
setTotal(res.pagination.total);
} catch (error) {
setDataSource([]);
@@ -118,8 +121,10 @@ const Models: React.FC = () => {
if (!firstLoad) {
createModelsChunkRequest();
}
createModelsChunkRequest();
return () => {
chunkRequedtRef.current?.current?.cancel?.();
cacheDataListRef.current = [];
};
}, [firstLoad]);