Fix duplicate node position entries in cytoscapeStore saveNodePosition

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RaRBJFZKSTA7naHGuQHfnQ
This commit is contained in:
2026-07-04 22:21:30 +08:00
co-authored by Claude Fable 5
parent 217c18659b
commit 7095db5ee9
2 changed files with 69 additions and 12 deletions
+6 -12
View File
@@ -26,8 +26,8 @@ export interface Node {
}
export interface NodePositions {
[direction: string]: {
[graphId: string]: Node[];
[graphId: string]: {
[direction: string]: Node[];
}
}
@@ -51,16 +51,10 @@ export const useCytoscapeStore = defineStore('cytoscapeStore', {
if (!this.nodePositions[this.currentGraphId][direction]) {
this.nodePositions[this.currentGraphId][direction] = [];
}
// If this graph's data was previously stored in localStorage
if (localStorage.getItem(SAVE_KEY_NAME)) {
const nodeToSave = this.nodePositions[this.currentGraphId][direction]
.find(node => node.id === nodeId);
if (nodeToSave) {
nodeToSave.position = position;
} else {
this.nodePositions[this.currentGraphId][direction]
.push({ id: nodeId, position: position });
}
const nodeToSave = this.nodePositions[this.currentGraphId][direction]
.find(node => node.id === nodeId);
if (nodeToSave) {
nodeToSave.position = position;
} else {
this.nodePositions[this.currentGraphId][direction]
.push({ id: nodeId, position: position });