diff --git a/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDViewer.tsx b/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDViewer.tsx index 73ddb075..38532bd1 100644 --- a/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDViewer.tsx +++ b/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDViewer.tsx @@ -19,6 +19,7 @@ import {Box} from "@mui/material"; import {ColoringOptions, getColor} from "../../../helpers/twoD/coloringHelper"; import ContextMenu from "./ContextMenu"; import {computeGraphDifferences, updateHighlighted} from "../../../helpers/twoD/graphRendering.ts"; +import {areSetsEqual} from "../../../helpers/utils.ts"; cytoscape.use(fcose); cytoscape.use(dagre); @@ -118,7 +119,7 @@ const TwoDViewer = () => { if (cyRef.current) { updateGraphElements(cyRef.current, connections); } - }, [connections, hiddenNodes, workspace.neuronGroups, includePostEmbryonic]); + }, [connections, hiddenNodes, workspace.neuronGroups, includePostEmbryonic, splitJoinState]); useEffect(() => { if (cyRef.current) { @@ -241,7 +242,9 @@ const TwoDViewer = () => { } }); - workspace.setActiveNeurons(activeNeurons); + if(!areSetsEqual(activeNeurons, workspace.activeNeurons)){ + workspace.setActiveNeurons(activeNeurons); + } }, [splitJoinState, workspace.id]); // Effect to handle includeLabels state diff --git a/applications/visualizer/frontend/src/helpers/utils.ts b/applications/visualizer/frontend/src/helpers/utils.ts new file mode 100644 index 00000000..a35af0f6 --- /dev/null +++ b/applications/visualizer/frontend/src/helpers/utils.ts @@ -0,0 +1,11 @@ +export function areSetsEqual(setA: Set, setB: Set): boolean { + if (setA.size !== setB.size) { + return false; + } + for (let item of setA) { + if (!setB.has(item)) { + return false; + } + } + return true; +} \ No newline at end of file