From 1e5b90d10a02aed3a4b2cc2a53442856576f177d Mon Sep 17 00:00:00 2001 From: -LAN- Date: Fri, 11 Oct 2024 03:06:42 +0800 Subject: [PATCH] fix(log list): prevent duplicate data fetch Ensure data is fetched only once by tracking fetch initiation with a useRef hook. This avoids unnecessary repeated network calls when conditions are met, improving efficiency and performance. --- web/app/components/app/log/list.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/app/components/app/log/list.tsx b/web/app/components/app/log/list.tsx index 149e877fa4ac2d..7dff48c20a28ec 100644 --- a/web/app/components/app/log/list.tsx +++ b/web/app/components/app/log/list.tsx @@ -299,10 +299,14 @@ function DetailPanel { - if (appDetail?.id && detail.id && appDetail?.mode !== 'completion') + if (appDetail?.id && detail.id && appDetail?.mode !== 'completion' && !fetchInitiated.current) { + fetchInitiated.current = true fetchData() - }, [appDetail?.id, detail.id, appDetail?.mode]) + } + }, [appDetail?.id, detail.id, appDetail?.mode, fetchData]) const isChatMode = appDetail?.mode !== 'completion' const isAdvanced = appDetail?.mode === 'advanced-chat'