yangdx
commited on
Commit
·
8a62e69
1
Parent(s):
6f4639a
Remove redundant sigma instance setup code in GraphViewer component
Browse files
lightrag/api/webui/assets/{index-B11jRN0T.js → index-B_8hp7Xk.js}
RENAMED
Binary files a/lightrag/api/webui/assets/index-B11jRN0T.js and b/lightrag/api/webui/assets/index-B_8hp7Xk.js differ
|
|
lightrag/api/webui/index.html
CHANGED
Binary files a/lightrag/api/webui/index.html and b/lightrag/api/webui/index.html differ
|
|
lightrag_webui/src/components/graph/GraphControl.tsx
CHANGED
@@ -75,7 +75,7 @@ const GraphControl = ({ disableHoverEffect }: { disableHoverEffect?: boolean })
|
|
75 |
// Double-check that the store has the sigma instance
|
76 |
const currentInstance = useGraphStore.getState().sigmaInstance;
|
77 |
if (!currentInstance) {
|
78 |
-
console.log('Setting sigma instance from GraphControl
|
79 |
useGraphStore.getState().setSigmaInstance(sigma);
|
80 |
}
|
81 |
}
|
|
|
75 |
// Double-check that the store has the sigma instance
|
76 |
const currentInstance = useGraphStore.getState().sigmaInstance;
|
77 |
if (!currentInstance) {
|
78 |
+
console.log('Setting sigma instance from GraphControl');
|
79 |
useGraphStore.getState().setSigmaInstance(sigma);
|
80 |
}
|
81 |
}
|
lightrag_webui/src/features/GraphViewer.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import { useEffect,
|
2 |
import { useTabVisibility } from '@/contexts/useTabVisibility'
|
3 |
// import { MiniMap } from '@react-sigma/minimap'
|
4 |
import { SigmaContainer, useRegisterEvents, useSigma } from '@react-sigma/core'
|
@@ -157,39 +157,9 @@ const GraphViewer = () => {
|
|
157 |
};
|
158 |
}, []);
|
159 |
|
160 |
-
//
|
161 |
-
|
162 |
-
|
163 |
-
// Set the sigma instance in the graph store when it's available
|
164 |
-
// Using useLayoutEffect to ensure this runs before child components need the instance
|
165 |
-
useLayoutEffect(() => {
|
166 |
-
if (sigmaRef.current?.sigma) {
|
167 |
-
const instance = sigmaRef.current.sigma;
|
168 |
-
|
169 |
-
// Get the sigma instance from the ref and store it
|
170 |
-
console.log('Setting sigma instance in graph store (layout effect)');
|
171 |
-
useGraphStore.getState().setSigmaInstance(instance);
|
172 |
-
|
173 |
-
// If we also have a graph, bind it to the sigma instance
|
174 |
-
if (sigmaGraph) {
|
175 |
-
try {
|
176 |
-
// Try to set the graph on the sigma instance
|
177 |
-
if (typeof instance.setGraph === 'function') {
|
178 |
-
instance.setGraph(sigmaGraph);
|
179 |
-
console.log('Directly set graph on sigma instance in GraphViewer');
|
180 |
-
} else {
|
181 |
-
// If setGraph method doesn't exist, try to set the graph property directly
|
182 |
-
(instance as any).graph = sigmaGraph;
|
183 |
-
console.log('Set graph property on sigma instance in GraphViewer');
|
184 |
-
}
|
185 |
-
} catch (error) {
|
186 |
-
console.error('Error setting graph on sigma instance in GraphViewer:', error);
|
187 |
-
}
|
188 |
-
}
|
189 |
-
}
|
190 |
-
// We want this to run when either the ref or the graph changes
|
191 |
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
192 |
-
}, [sigmaRef.current, sigmaGraph]);
|
193 |
|
194 |
const onSearchFocus = useCallback((value: GraphSearchOption | null) => {
|
195 |
if (value === null) useGraphStore.getState().setFocusedNode(null)
|
|
|
1 |
+
import { useEffect, useState, useCallback, useMemo, useRef } from 'react'
|
2 |
import { useTabVisibility } from '@/contexts/useTabVisibility'
|
3 |
// import { MiniMap } from '@react-sigma/minimap'
|
4 |
import { SigmaContainer, useRegisterEvents, useSigma } from '@react-sigma/core'
|
|
|
157 |
};
|
158 |
}, []);
|
159 |
|
160 |
+
// Note: There was a useLayoutEffect hook here to set up the sigma instance and graph data,
|
161 |
+
// but testing showed it wasn't executing or having any effect, while the backup mechanism
|
162 |
+
// in GraphControl was sufficient. This code was removed to simplify implementation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
164 |
const onSearchFocus = useCallback((value: GraphSearchOption | null) => {
|
165 |
if (value === null) useGraphStore.getState().setFocusedNode(null)
|