yangdx commited on
Commit
5a328de
·
1 Parent(s): 6b24674

Fix empty graph check problem of graph view load

Browse files
lightrag_webui/src/components/graph/ZoomControl.tsx CHANGED
@@ -27,7 +27,8 @@ const ZoomControl = () => {
27
  const graph = sigma.getGraph()
28
 
29
  // Check if graph has nodes before accessing them
30
- if (!graph || graph.nodes().length === 0) {
 
31
  reset()
32
  return
33
  }
@@ -73,6 +74,8 @@ const ZoomControl = () => {
73
  )
74
  } catch (error) {
75
  console.error('Error resetting zoom:', error)
 
 
76
  }
77
  }, [sigma, reset])
78
 
 
27
  const graph = sigma.getGraph()
28
 
29
  // Check if graph has nodes before accessing them
30
+ if (!graph?.order || graph.nodes().length === 0) {
31
+ // Use reset() for empty graph case
32
  reset()
33
  return
34
  }
 
74
  )
75
  } catch (error) {
76
  console.error('Error resetting zoom:', error)
77
+ // Use reset() as fallback on error
78
+ reset()
79
  }
80
  }, [sigma, reset])
81