From 4f4d7cbd4c486eeb739deaf9a8cbbea20a5f4564 Mon Sep 17 00:00:00 2001 From: yangdx Date: Sat, 15 Mar 2025 16:01:03 +0800 Subject: [PATCH] Fix empty graph check problem of graph view load --- lightrag_webui/src/components/graph/ZoomControl.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lightrag_webui/src/components/graph/ZoomControl.tsx b/lightrag_webui/src/components/graph/ZoomControl.tsx index 5739ea67..b978c3b0 100644 --- a/lightrag_webui/src/components/graph/ZoomControl.tsx +++ b/lightrag_webui/src/components/graph/ZoomControl.tsx @@ -27,7 +27,8 @@ const ZoomControl = () => { const graph = sigma.getGraph() // Check if graph has nodes before accessing them - if (!graph || graph.nodes().length === 0) { + if (!graph?.order || graph.nodes().length === 0) { + // Use reset() for empty graph case reset() return } @@ -73,6 +74,8 @@ const ZoomControl = () => { ) } catch (error) { console.error('Error resetting zoom:', error) + // Use reset() as fallback on error + reset() } }, [sigma, reset])