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 68ea374d6..5ffb55527 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 @@ -196,6 +196,11 @@ RED.nodes = (function() { if (n.type.indexOf("subflow") !== 0) { n["_"] = n._def._; } else { + var subflowId = n.type.substring(8); + var sf = RED.nodes.subflow(subflowId); + if (sf) { + sf.instances.push(sf); + } n["_"] = RED._; } if (n._def.category == "config") { @@ -284,6 +289,15 @@ RED.nodes = (function() { } } } + + if (node.type.indexOf("subflow:") === 0) { + var subflowId = node.type.substring(8); + var sf = RED.nodes.subflow(subflowId); + if (sf) { + sf.instances.splice(sf.instances.indexOf(node),1); + } + } + if (updatedConfigNode) { RED.workspaces.refresh(); } @@ -297,6 +311,9 @@ RED.nodes = (function() { RED.events.emit('nodes:remove',node); } } + + + if (node && node._def.onremove) { // Deprecated: never documented but used by some early nodes console.log("Deprecated API warning: node type ",node.type," has an onremove function - should be oneditremove - please report"); @@ -459,6 +476,7 @@ RED.nodes = (function() { module: "node-red" } }); + sf.instances = []; sf._def = RED.nodes.getType("subflow:"+sf.id); RED.events.emit("subflows:add",sf); } diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js index 29e8ab06b..aacb89bcc 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js @@ -883,13 +883,13 @@ RED.editor = (function() { var userCount = 0; var subflowType = "subflow:"+node.id; - RED.nodes.eachNode(function(n) { - if (n.type === subflowType) { - userCount++; - } - }); + // RED.nodes.eachNode(function(n) { + // if (n.type === subflowType) { + // userCount++; + // } + // }); $("#red-ui-editor-subflow-user-count") - .text(RED._("subflow.subflowInstances", {count:userCount})).show(); + .text(RED._("subflow.subflowInstances", {count:node.instances.length})).show(); } $('
'+ diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js index 418939a72..78eb6e5b0 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js @@ -240,13 +240,8 @@ RED.sidebar.info = (function() { subflowNode = node; } - subflowUserCount = 0; var subflowType = "subflow:"+subflowNode.id; - RED.nodes.eachNode(function(n) { - if (n.type === subflowType) { - subflowUserCount++; - } - }); + subflowUserCount = subflowNode.instances.length; } propertiesPanelHeaderIcon.empty();