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:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user