Prevent duplicate links being added between nodes

This commit is contained in:
Nick O'Leary
2022-02-14 20:35:47 +00:00
parent 264047dc0c
commit 0261105c52

View File

@@ -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