diff --git a/packages/node_modules/@node-red/editor-api/lib/editor/comms.js b/packages/node_modules/@node-red/editor-api/lib/editor/comms.js index 386b5f8a8..9c96bbf5b 100644 --- a/packages/node_modules/@node-red/editor-api/lib/editor/comms.js +++ b/packages/node_modules/@node-red/editor-api/lib/editor/comms.js @@ -33,8 +33,6 @@ var activeConnections = []; var anonymousUser; -var retained = {}; - var heartbeatTimer; var lastSentTime; diff --git a/packages/node_modules/@node-red/nodes/core/common/21-debug.js b/packages/node_modules/@node-red/nodes/core/common/21-debug.js index 272f48016..0e00a8fff 100644 --- a/packages/node_modules/@node-red/nodes/core/common/21-debug.js +++ b/packages/node_modules/@node-red/nodes/core/common/21-debug.js @@ -21,8 +21,11 @@ module.exports = function(RED) { this.tosidebar = n.tosidebar; if (this.tosidebar === undefined) { this.tosidebar = true; } this.active = (n.active === null || typeof n.active === "undefined") || n.active; - if (this.tostatus) { this.status({fill:"grey", shape:"ring"}); } - else { this.status({}); } + if (this.tostatus) { + this.status({fill:"grey", shape:"ring"}); + this.oldState = "{}"; + } + var hasStatExpression = (n.statusType === "jsonata"); var statExpression = hasStatExpression ? n.statusVal : null; @@ -97,7 +100,11 @@ module.exports = function(RED) { } } } - + this.on("close", function() { + if (this.oldState) { + this.status({}); + } + }) this.on("input", function(msg, send, done) { if (msg.hasOwnProperty("status") && msg.status.hasOwnProperty("source") && msg.status.source.hasOwnProperty("id") && (msg.status.source.id === node.id)) { done(); @@ -202,13 +209,8 @@ module.exports = function(RED) { function setNodeState(node,state) { if (state) { node.active = true; - if (node.tostatus) { node.status({fill:"grey", shape:"dot"}); } } else { node.active = false; - if (node.tostatus && node.hasOwnProperty("oldStatus")) { - node.oldStatus.shape = "dot"; - node.status(node.oldStatus); - } } } diff --git a/packages/node_modules/@node-red/nodes/core/function/10-function.js b/packages/node_modules/@node-red/nodes/core/function/10-function.js index 69b0c202a..eb07c319d 100644 --- a/packages/node_modules/@node-red/nodes/core/function/10-function.js +++ b/packages/node_modules/@node-red/nodes/core/function/10-function.js @@ -127,6 +127,8 @@ module.exports = function(RED) { node.topic = n.topic; node.outstandingTimers = []; node.outstandingIntervals = []; + node.clearStatus = false; + var sandbox = { console:console, util:util, @@ -163,6 +165,7 @@ module.exports = function(RED) { node.on.apply(node, arguments); }, status: function() { + node.clearStatus = true; node.status.apply(node, arguments); } }, @@ -389,7 +392,9 @@ module.exports = function(RED) { while (node.outstandingIntervals.length > 0) { clearInterval(node.outstandingIntervals.pop()); } - node.status({}); + if (node.clearStatus) { + node.status({}); + } }); promise.then(function (v) { diff --git a/packages/node_modules/@node-red/runtime/lib/api/comms.js b/packages/node_modules/@node-red/runtime/lib/api/comms.js index 0652a651b..55789b806 100644 --- a/packages/node_modules/@node-red/runtime/lib/api/comms.js +++ b/packages/node_modules/@node-red/runtime/lib/api/comms.js @@ -38,12 +38,20 @@ function handleCommsEvent(event) { publish(event.topic,event.data,event.retain); } function handleStatusEvent(event) { - var status = { - text: event.status.text, - fill: event.status.fill, - shape: event.status.shape - }; - publish("status/"+event.id,status,true); + if (!event.status) { + delete retained["status/"+event.id] + } else if (!event.status.text && !event.status.fill && !event.status.shape) { + if (retained["status/"+event.id]) { + publish("status/"+event.id,{},false); + } + } else { + var status = { + text: event.status.text, + fill: event.status.fill, + shape: event.status.shape + }; + publish("status/"+event.id,status,true); + } } function handleRuntimeEvent(event) { runtime.log.trace("runtime event: "+JSON.stringify(event)); diff --git a/packages/node_modules/@node-red/runtime/lib/flows/Subflow.js b/packages/node_modules/@node-red/runtime/lib/flows/Subflow.js index 8b78cad17..78ec9ee75 100644 --- a/packages/node_modules/@node-red/runtime/lib/flows/Subflow.js +++ b/packages/node_modules/@node-red/runtime/lib/flows/Subflow.js @@ -18,6 +18,7 @@ const clone = require("clone"); const Flow = require('./Flow').Flow; const context = require('../nodes/context'); const util = require("util"); +const events = require("../events"); const redUtil = require("@node-red/util").util; const flowUtil = require("./util"); @@ -308,7 +309,26 @@ class Subflow extends Flow { super.start(diff); } + /** + * Stop this subflow. + * The `stopList` argument helps define what needs to be stopped in the case + * of a modified-nodes/flows type deploy. + * @param {[type]} stopList [description] + * @param {[type]} removedList [description] + * @return {[type]} [description] + */ + stop(stopList, removedList) { + const nodes = Object.keys(this.activeNodes); + return super.stop(stopList, removedList).then(res => { + nodes.forEach(id => { + events.emit("node-status",{ + id: id + }); + }) + return res; + }) + } /** * Get environment variable of subflow * @param {String} name name of env var