From eb40eff2d09c5b4c06bbabe5ed4f3764c08e2a35 Mon Sep 17 00:00:00 2001 From: Aaron Verones Date: Mon, 2 Sep 2024 09:05:08 -0400 Subject: [PATCH] fix: Nodes are undefined when connection.data.key doesn't exist --- main.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.ts b/main.ts index 828bd28..d484f63 100644 --- a/main.ts +++ b/main.ts @@ -1514,7 +1514,7 @@ class ScGraphItemView extends ItemView { const connectionId = connection.key; // console.log('Adding connection node for ID:', connectionId); - this.addConnectionNode(connection); + this.addConnectionNode(connectionId, connection); // console.log('Adding connection link for ID:', connectionId); this.addConnectionLink(connectionId, connection); @@ -1526,12 +1526,12 @@ class ScGraphItemView extends ItemView { // console.log('Links after addFilteredConnections:', this.links); } - addConnectionNode(connection: any) { - if (!this.nodes.some((node: { id: string; }) => node.id === connection.data.key)) { + addConnectionNode(connectionId: any, connection: any) { + if (!this.nodes.some((node: { id: string; }) => node.id === connectionId)) { this.nodes.push({ - id: connection.data.key, - name: connection.data.key, - group: (connection instanceof this.env.item_types.SmartBlock) ? 'block' : 'note', + id: connectionId, + name: connectionId, + group: (connection instanceof this.env.item_types.SmartBlock) ? 'block' : 'note', x: Math.random() * 1000, y: Math.random() * 1000, fx: null, @@ -1541,7 +1541,7 @@ class ScGraphItemView extends ItemView { highlighted: false }); } else { - console.log('Node already exists for connection ID:',connection.data.key); + console.log('Node already exists for connection ID:',connectionId); } }