From 47ced11e03fa6e7014d80f663233b734bc4c1398 Mon Sep 17 00:00:00 2001 From: jialin Date: Fri, 17 Jan 2025 23:38:05 +0800 Subject: [PATCH] fix: reset update instance list flag --- src/pages/llmodels/components/table-list.tsx | 18 +++++++++++++++++- src/pages/llmodels/index.tsx | 1 - 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/pages/llmodels/components/table-list.tsx b/src/pages/llmodels/components/table-list.tsx index 05a61a43..447c2657 100644 --- a/src/pages/llmodels/components/table-list.tsx +++ b/src/pages/llmodels/components/table-list.tsx @@ -144,6 +144,7 @@ const Models: React.FC = ({ defaultSortOrder: 'descend' }); + const updateRef = useRef(false); const [openLogModal, setOpenLogModal] = useState(false); const [openAddModal, setOpenAddModal] = useState(false); const [openDeployModal, setOpenDeployModal] = useState({ @@ -673,10 +674,11 @@ const Models: React.FC = ({ const renderChildren = useCallback( (list: any, parent?: any) => { let childList = list; - if (allInstances.length) { + if (allInstances.length && !updateRef.current) { childList = list.filter((item: any) => { return allInstances.some((instance) => instance.id === item.id); }); + updateRef.current = true; } return ( = ({ } }; + useEffect(() => { + const handleVisibilityChange = async () => { + if (document.visibilityState === 'hidden') { + updateRef.current = false; + } + }; + + document.addEventListener('visibilitychange', handleVisibilityChange); + + return () => { + document.removeEventListener('visibilitychange', handleVisibilityChange); + }; + }, []); + return ( <> { const data: any = await queryModelsInstances(params, { token: instancesToken.current?.token }); - console.log('instance====', data); setAllInstances(data.items || []); } catch (error) { // ignore