Fix Graph TAB flickering issue in node expansion

This commit is contained in:
yangdx
2025-03-15 17:03:08 +08:00
parent 4f4d7cbd4c
commit 97696ddb76

View File

@@ -339,14 +339,10 @@ const useLightrangeGraph = () => {
if (!nodeId || !sigmaGraph || !rawGraph) return; if (!nodeId || !sigmaGraph || !rawGraph) return;
try { try {
// Set fetching state
useGraphStore.getState().setIsFetching(true);
// Get the node to expand // Get the node to expand
const nodeToExpand = rawGraph.getNode(nodeId); const nodeToExpand = rawGraph.getNode(nodeId);
if (!nodeToExpand) { if (!nodeToExpand) {
console.error('Node not found:', nodeId); console.error('Node not found:', nodeId);
useGraphStore.getState().setIsFetching(false);
return; return;
} }
@@ -354,7 +350,6 @@ const useLightrangeGraph = () => {
const label = nodeToExpand.labels[0]; const label = nodeToExpand.labels[0];
if (!label) { if (!label) {
console.error('Node has no label:', nodeId); console.error('Node has no label:', nodeId);
useGraphStore.getState().setIsFetching(false);
return; return;
} }
@@ -363,7 +358,6 @@ const useLightrangeGraph = () => {
if (!extendedGraph || !extendedGraph.nodes || !extendedGraph.edges) { if (!extendedGraph || !extendedGraph.nodes || !extendedGraph.edges) {
console.error('Failed to fetch extended graph'); console.error('Failed to fetch extended graph');
useGraphStore.getState().setIsFetching(false);
return; return;
} }
@@ -439,7 +433,6 @@ const useLightrangeGraph = () => {
// If no new connectable nodes found, show toast and return // If no new connectable nodes found, show toast and return
if (nodesToAdd.size === 0) { if (nodesToAdd.size === 0) {
toast.info(t('graphPanel.propertiesView.node.noNewNodes')); toast.info(t('graphPanel.propertiesView.node.noNewNodes'));
useGraphStore.getState().setIsFetching(false);
return; return;
} }
@@ -610,9 +603,6 @@ const useLightrangeGraph = () => {
} catch (error) { } catch (error) {
console.error('Error expanding node:', error); console.error('Error expanding node:', error);
} finally {
// Reset fetching state
useGraphStore.getState().setIsFetching(false);
} }
}; };