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]);
const debounceUpdateChunckedList = () => {
clearTimeout(timerRef.current);
timerRef.current = setTimeout(() => {
options.setDataList?.([...cacheDataListRef.current]);
}, 80);
// clearTimeout(timerRef.current);
// timerRef.current = setTimeout(() => {
// options.setDataList?.([...cacheDataListRef.current]);
// }, 80);
options.setDataList?.([...cacheDataListRef.current]);
};
const updateChunkedList = (data: ChunkedCollection) => {
console.log('updateChunkedList=====', {
@@ -406,9 +406,6 @@ const Models: React.FC<ModelsProps> = ({
name: row.name,
async onOk() {
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, {
cancelToken: axiosToken.token
});
if (!firstLoad) {
setDataSource({
dataList: res.items || [],
loading: false,
total: res.pagination.total
});
} else {
setDataSource({
...dataSource,
loading: !!res.items.length,
total: res.pagination.total
});
}
setDataSource({
dataList: res.items || [],
loading: false,
total: res.pagination.total
});
} catch (error) {
setDataSource({
dataList: [],