Improve graph state cleanup by fully resetting sigma instance on label change
• Modify reset logic to clear sigma instance • Remove manual node deletion • Update GraphLabels to use reset() • Simplify state cleanup process • Ensure complete graph refresh
This commit is contained in:
@@ -142,22 +142,13 @@ const useGraphStoreBase = create<GraphState>()((set, get) => ({
|
||||
focusedEdge: null
|
||||
}),
|
||||
reset: () => {
|
||||
// Get the existing graph
|
||||
const existingGraph = get().sigmaGraph;
|
||||
|
||||
// If we have an existing graph, clear it by removing all nodes
|
||||
if (existingGraph) {
|
||||
const nodes = Array.from(existingGraph.nodes());
|
||||
nodes.forEach(node => existingGraph.dropNode(node));
|
||||
}
|
||||
|
||||
set({
|
||||
selectedNode: null,
|
||||
focusedNode: null,
|
||||
selectedEdge: null,
|
||||
focusedEdge: null,
|
||||
rawGraph: null,
|
||||
// Keep the existing graph instance but with cleared data
|
||||
sigmaGraph: null, // 完全清除图形实例
|
||||
moveToSelectedNode: false,
|
||||
shouldRender: false
|
||||
});
|
||||
|
Reference in New Issue
Block a user