Fix Group import and user deletion (bad object reference)

This commit is contained in:
GogoVega 2024-06-20 12:08:48 +02:00
parent e6fa0514ed
commit 5d78c546bc
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B

View File

@ -680,7 +680,7 @@ RED.nodes = (function() {
if (n.wires && (n.wires.length > n.outputs)) { n.outputs = n.wires.length; }
n.dirty = true;
// TODO: The event should be triggered?
updateConfigNodeUsers(n, { action: "add", emitEvent: false });
updateConfigNodeUsers(newNode, { action: "add" });
// TODO: What is this property used for?
if (n._def.category == "subflows" && typeof n.i === "undefined") {
var nextId = 0;
@ -754,6 +754,9 @@ RED.nodes = (function() {
delete nodeLinks[id];
removedLinks = links.filter(function(l) { return (l.source === node) || (l.target === node); });
removedLinks.forEach(removeLink);
// TODO: The event should not be triggered?
updateConfigNodeUsers(node, { action: "remove" });
var updatedConfigNode = false;
for (var d in node._def.defaults) {
if (node._def.defaults.hasOwnProperty(d)) {
@ -764,13 +767,10 @@ RED.nodes = (function() {
var configNode = configNodes[node[d]];
if (configNode) {
updatedConfigNode = true;
// TODO: Not sure if still exists
if (configNode._def.exclusive) {
removeNode(node[d]);
removedNodes.push(configNode);
} else {
var users = configNode.users;
users.splice(users.indexOf(node),1);
RED.events.emit('nodes:change',configNode)
}
}
}
@ -2337,7 +2337,8 @@ RED.nodes = (function() {
}
}
const isConfigNode = def?.category === "config";
// TODO: Group Node has config as category - why?
const isConfigNode = def?.category === "config" && node.type !== "group";
// Now the properties have been fixed, copy the node properties:
// NOTE: If the Node def is unknown, user properties will not be copied