diff --git a/red/nodes/Flow.js b/red/nodes/Flow.js index 65f643cac..2e026af1f 100644 --- a/red/nodes/Flow.js +++ b/red/nodes/Flow.js @@ -537,6 +537,7 @@ function diffFlow(flow,config) { var flowNodes = {}; var changedNodes = {}; var deletedNodes = {}; + var deletedSubflows = {}; var deletedTabs = {}; var linkChangedNodes = {}; @@ -591,10 +592,12 @@ function diffFlow(flow,config) { flow.config.forEach(function(node) { if (!flowNodes[node.id]) { - if (node.type != "tab") { - deletedNodes[node.id] = node; - } else { + if (node.type === "tab") { deletedTabs[node.id] = node; + } else if (node.type === "subflow") { + deletedSubflows[node.id] = node; + } else { + deletedNodes[node.id] = node; } } buildNodeLinks(activeLinks,node,flow.allNodes); @@ -720,9 +723,8 @@ function diffFlow(flow,config) { // var n = flow.allNodes[id]; // console.log("[ ] [ ] [D]",n.id,n.type); // }); - var diff = { - deleted: Object.keys(deletedNodes).filter(function(id) { return deletedNodes[id].type != "subflow" && (!deletedNodes[id].z || deletedTabs[deletedNodes[id].z] || flowNodes[deletedNodes[id].z].type != "subflow")}), + deleted: Object.keys(deletedNodes).filter(function(id) { return deletedNodes[id].type != "subflow" && (!deletedNodes[id].z || deletedTabs[deletedNodes[id].z] || !(deletedSubflows[deletedNodes[id].z] || flowNodes[deletedNodes[id].z].type == "subflow"))}), changed: Object.keys(changedNodes).filter(function(id) { return changedNodes[id].type != "subflow" && (!changedNodes[id].z || flowNodes[changedNodes[id].z].type != "subflow")}), linked: Object.keys(linkChangedNodes).filter(function(id) { return linkChangedNodes[id].type != "subflow" && (!linkChangedNodes[id].z || flowNodes[linkChangedNodes[id].z].type != "subflow")}), wiringChanged: []