Skip to content

Commit

Permalink
Merge pull request #14 from aaronVerones/aaron.verones/fix-nodes-unde…
Browse files Browse the repository at this point in the history
…fined

fix: Nodes are undefined when connection.data.key doesn't exist
  • Loading branch information
Mossy1022 authored Sep 11, 2024
2 parents 52c9fbc + eb40eff commit 2cda805
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 2cda805

Please sign in to comment.