From 283189a17c78cad8a0c27a1d1163b4c394286ecc Mon Sep 17 00:00:00 2001 From: jialin Date: Fri, 30 May 2025 11:22:23 +0800 Subject: [PATCH] fix: model instances always update by cache --- .../seal-table/components/table-row.tsx | 3 --- src/pages/llmodels/components/table-list.tsx | 9 ++++++++- src/pages/llmodels/index.tsx | 18 ++++-------------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/components/seal-table/components/table-row.tsx b/src/components/seal-table/components/table-row.tsx index 2d2be661..854559fd 100644 --- a/src/components/seal-table/components/table-row.tsx +++ b/src/components/seal-table/components/table-row.tsx @@ -136,9 +136,6 @@ const TableRow: React.FC< }, [record, loadChildren]); const filterUpdateChildrenHandler = () => { - if (!expandedRowKeys?.includes(record[rowKey])) { - return; - } const dataList = _.filter(tableContext.allChildren, (data: any) => { return _.get(data, [childParentKey]) === _.get(record, [rowKey]); }); diff --git a/src/pages/llmodels/components/table-list.tsx b/src/pages/llmodels/components/table-list.tsx index 34db0ed7..fe727e56 100644 --- a/src/pages/llmodels/components/table-list.tsx +++ b/src/pages/llmodels/components/table-list.tsx @@ -503,7 +503,14 @@ const Models: React.FC = ({ // ignore } }, - [handleEdit, handleOpenPlayGround, handleDelete, expandedRowKeys] + [ + handleEdit, + handleOpenPlayGround, + handleDelete, + onStop, + onStart, + expandedRowKeys + ] ); const handleChildSelect = useCallback( diff --git a/src/pages/llmodels/index.tsx b/src/pages/llmodels/index.tsx index 803c031e..d0209d1f 100644 --- a/src/pages/llmodels/index.tsx +++ b/src/pages/llmodels/index.tsx @@ -252,24 +252,14 @@ const Models: React.FC = () => { }); }, [fetchData, createModelsChunkRequest, createModelsInstanceChunkRequest]); - const handleOnStop = useCallback(async (ids: number[]) => { - cacheInsDataListRef.current = cacheInsDataListRef.current.filter( - (item: any) => !ids.includes(item.model_id) - ); + const handleSearchBySilent = useCallback(async () => { await new Promise((resolve) => { setTimeout(resolve, 300); }); - setModelInstances(cacheInsDataListRef.current); fetchData({ loadingVal: false }); - }, []); - - const handleOnStart = useCallback(() => { - fetchData({ - loadingVal: false - }); - }, []); + }, [fetchData]); const handleSearch = useCallback( async (params?: any) => { @@ -480,8 +470,8 @@ const Models: React.FC = () => { handleOnToggleExpandAll={createModelsInstanceChunkRequest} onViewLogs={handleOnViewLogs} onCancelViewLogs={handleOnCancelViewLogs} - onStop={handleOnStop} - onStart={handleOnStart} + onStop={handleSearchBySilent} + onStart={handleSearchBySilent} queryParams={queryParams} loading={dataSource.loading} loadend={dataSource.loadend}