fix: delay in updating model list

This commit is contained in:
jialin
2024-12-12 16:28:14 +08:00
parent dde746a5fe
commit 85949c5927
3 changed files with 11 additions and 20 deletions
+5 -4
View File
@@ -27,10 +27,11 @@ export function useUpdateChunkedList(options: {
}, [options.dataList]); }, [options.dataList]);
const debounceUpdateChunckedList = () => { const debounceUpdateChunckedList = () => {
clearTimeout(timerRef.current); // clearTimeout(timerRef.current);
timerRef.current = setTimeout(() => { // timerRef.current = setTimeout(() => {
options.setDataList?.([...cacheDataListRef.current]); // options.setDataList?.([...cacheDataListRef.current]);
}, 80); // }, 80);
options.setDataList?.([...cacheDataListRef.current]);
}; };
const updateChunkedList = (data: ChunkedCollection) => { const updateChunkedList = (data: ChunkedCollection) => {
console.log('updateChunkedList=====', { console.log('updateChunkedList=====', {
@@ -406,9 +406,6 @@ const Models: React.FC<ModelsProps> = ({
name: row.name, name: row.name,
async onOk() { async onOk() {
await deleteModelInstance(row.id); await deleteModelInstance(row.id);
if (list.length === 1) {
removeExpandedRowKey([row.model_id]);
}
} }
}); });
}; };
+6 -13
View File
@@ -87,19 +87,12 @@ const Models: React.FC = () => {
const res: any = await queryModelsList(params, { const res: any = await queryModelsList(params, {
cancelToken: axiosToken.token cancelToken: axiosToken.token
}); });
if (!firstLoad) {
setDataSource({ setDataSource({
dataList: res.items || [], dataList: res.items || [],
loading: false, loading: false,
total: res.pagination.total total: res.pagination.total
}); });
} else {
setDataSource({
...dataSource,
loading: !!res.items.length,
total: res.pagination.total
});
}
} catch (error) { } catch (error) {
setDataSource({ setDataSource({
dataList: [], dataList: [],