From 72b8dbb45b8c2699b2b7e83f58ea49946348ebf0 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Tue, 4 Sep 2018 22:54:28 +0100 Subject: [PATCH] Split node - fix complete to send msg for k/v object and update info to try to clarify. --- nodes/core/logic/17-split.html | 3 ++- nodes/core/logic/17-split.js | 19 +++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/nodes/core/logic/17-split.html b/nodes/core/logic/17-split.html index 5d1e6e6dd..fccb8c0d0 100644 --- a/nodes/core/logic/17-split.html +++ b/nodes/core/logic/17-split.html @@ -295,7 +295,8 @@ For object outputs, once this count has been reached, the node can be configured to send a message for each subsequent message received.

A timeout can be set to trigger sending the new message using whatever has been received so far.

-

If a message is received with the msg.complete property set, the output message is sent.

+

If a message is received with the msg.complete property set, the output message is finalised and sent. + This resets any part counts.

Reduce Sequence mode

When configured to join in reduce mode, an expression is applied to each diff --git a/nodes/core/logic/17-split.js b/nodes/core/logic/17-split.js index 3170ba584..f5ad199ca 100644 --- a/nodes/core/logic/17-split.js +++ b/nodes/core/logic/17-split.js @@ -586,7 +586,10 @@ module.exports = function(RED) { } else { if (msg.hasOwnProperty('complete')) { - completeSend(partId); + if (inflight[partId]) { + inflight[partId].msg.complete = msg.complete; + completeSend(partId); + } } else { node.warn("Message missing key property 'msg."+node.key+"' - cannot add to object") @@ -594,6 +597,7 @@ module.exports = function(RED) { } return; } + if (!inflight.hasOwnProperty(partId)) { if (payloadType === 'object' || payloadType === 'merged') { inflight[partId] = { @@ -604,19 +608,6 @@ module.exports = function(RED) { msg:RED.util.cloneMessage(msg) }; } - else if (node.accumulate === true) { - if (msg.hasOwnProperty("reset")) { delete inflight[partId]; } - inflight[partId] = inflight[partId] || { - currentCount:0, - payload:{}, - targetCount:targetCount, - type:payloadType, - msg:RED.util.cloneMessage(msg) - } - if (payloadType === 'string' || payloadType === 'array' || payloadType === 'buffer') { - inflight[partId].payload = []; - } - } else { inflight[partId] = { currentCount:0,