Fix number of users when replacing config nodes

This commit is contained in:
GogoVega 2024-06-19 16:28:18 +02:00
parent 58d4c36600
commit ee295e3c3f
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B

View File

@ -1728,6 +1728,7 @@ RED.nodes = (function() {
// Remove the old subflow definition - but leave the instances in place
var removalResult = RED.subflow.removeSubflow(n.id, true);
// Create the list of nodes for the new subflow def
// Need to sort the list in order to remove missing nodes
var subflowNodes = [n].concat(zMap[n.id]).filter((s) => !!s);
// Import the new subflow - no clashes should occur as we've removed
// the old version
@ -1765,9 +1766,20 @@ RED.nodes = (function() {
// Replace config nodes
//
configNodeIds.forEach(function(id) {
removedNodes = removedNodes.concat(convertNode(getNode(id)));
const configNode = getNode(id);
const currentUserCount = configNode.users;
// Add a snapshot of the Config Node
removedNodes = removedNodes.concat(convertNode(configNode));
// Remove the Config Node instance
removeNode(id);
importNodes([newConfigNodes[id]])
// Import the new one
importNodes([newConfigNodes[id]]);
// Re-attributes the user count
getNode(id).users = currentUserCount;
});
return {