From 0261105c526ad5cc7e0447f7d2a79e4398474a92 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 14 Feb 2022 20:35:47 +0000 Subject: [PATCH] Prevent duplicate links being added between nodes --- .../node_modules/@node-red/editor-client/src/js/nodes.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index 78b9deae6..ab7fae401 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -600,6 +600,14 @@ RED.nodes = (function() { RED.events.emit('nodes:add',n); } function addLink(l) { + if (nodeLinks[l.source.id]) { + const isUnique = nodeLinks[l.source.id].out.every(function(link) { + return link.sourcePort !== l.sourcePort || link.target.id !== l.target.id + }) + if (!isUnique) { + return + } + } links.push(l); if (l.source) { // Possible the node hasn't been added yet