From 8567f1655e1059ccce1ca1bc51a14d1e7e83391c Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 16 May 2019 14:42:41 +0100 Subject: [PATCH] Only redraw node status when it has changed --- .../@node-red/editor-client/src/js/red.js | 3 +- .../@node-red/editor-client/src/js/ui/view.js | 36 ++++++++++--------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/red.js b/packages/node_modules/@node-red/editor-client/src/js/red.js index f6b7d65d4..13a451ddf 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/red.js +++ b/packages/node_modules/@node-red/editor-client/src/js/red.js @@ -353,6 +353,7 @@ var RED = (function() { } } node.status = msg; + node.dirtyStatus = true; node.dirty = true; RED.view.redraw(); } @@ -579,7 +580,7 @@ var RED = (function() { } options.target = $("#red-ui-editor"); options.target.addClass("red-ui-editor"); - + buildEditor(options); RED.i18n.init(options, function() { RED.settings.init(options, loadEditor); diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js index b0ab85e72..614ab532e 100755 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js @@ -3036,23 +3036,27 @@ RED.view = (function() { // }); } - if (!showStatus || !d.status) { - thisNode.selectAll(".red-ui-flow-node-status-group").style("display","none"); - } else { - var fill = status_colours[d.status.fill]; // Only allow our colours for now - if (d.status.shape == null && fill == null) { - thisNode.selectAll(".red-ui-flow-node-status").style("display","none"); - thisNode.selectAll(".red-ui-flow-node-status-group").style("display","inline").attr("transform","translate(-14,"+(d.h+3)+")"); + if (d.dirtyStatus) { + if (!showStatus || !d.status) { + thisNode.selectAll(".red-ui-flow-node-status-group").style("display","none"); } else { - thisNode.selectAll(".red-ui-flow-node-status-group").style("display","inline").attr("transform","translate(3,"+(d.h+3)+")"); - var statusClass = "red-ui-flow-node-status-"+(d.status.shape||"dot")+"-"+d.status.fill; - thisNode.selectAll(".red-ui-flow-node-status").attr("class","red-ui-flow-node-status "+statusClass); - } - if (d.status.text) { - thisNode.selectAll(".red-ui-flow-node-status-label").text(d.status.text); - } else { - thisNode.selectAll(".red-ui-flow-node-status-label").text(""); + thisNode.selectAll(".red-ui-flow-node-status-group").style("display","inline"); + var fill = status_colours[d.status.fill]; // Only allow our colours for now + if (d.status.shape == null && fill == null) { + thisNode.selectAll(".red-ui-flow-node-status").style("display","none"); + thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(-14,"+(d.h+3)+")"); + } else { + thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(3,"+(d.h+3)+")"); + var statusClass = "red-ui-flow-node-status-"+(d.status.shape||"dot")+"-"+d.status.fill; + thisNode.selectAll(".red-ui-flow-node-status").attr("class","red-ui-flow-node-status "+statusClass); + } + if (d.status.text) { + thisNode.selectAll(".red-ui-flow-node-status-label").text(d.status.text); + } else { + thisNode.selectAll(".red-ui-flow-node-status-label").text(""); + } } + delete d.dirtyStatus; } d.dirty = false; @@ -3454,7 +3458,7 @@ RED.view = (function() { } function toggleStatus(s) { showStatus = s; - RED.nodes.eachNode(function(n) { n.dirty = true;}); + RED.nodes.eachNode(function(n) { n.dirtyStatus = true; n.dirty = true;}); //TODO: subscribe/unsubscribe here redraw(); }