mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge branch 'dev' into pr_4387
This commit is contained in:
@@ -42,6 +42,7 @@ function Node(n) {
|
||||
this._closeCallbacks = [];
|
||||
this._inputCallback = null;
|
||||
this._inputCallbacks = null;
|
||||
this._expectedDoneCount = 0;
|
||||
|
||||
if (n.name) {
|
||||
this.name = n.name;
|
||||
@@ -159,6 +160,9 @@ Node.prototype.on = function(event, callback) {
|
||||
if (event == "close") {
|
||||
this._closeCallbacks.push(callback);
|
||||
} else if (event === "input") {
|
||||
if (callback.length === 3) {
|
||||
this._expectedDoneCount++
|
||||
}
|
||||
if (this._inputCallback) {
|
||||
this._inputCallbacks = [this._inputCallback, callback];
|
||||
this._inputCallback = null;
|
||||
@@ -218,19 +222,17 @@ Node.prototype._emitInput = function(arg) {
|
||||
} else if (node._inputCallbacks) {
|
||||
// Multiple callbacks registered. Call each one, tracking eventual completion
|
||||
var c = node._inputCallbacks.length;
|
||||
let doneCount = 0
|
||||
for (var i=0;i<c;i++) {
|
||||
var cb = node._inputCallbacks[i];
|
||||
if (cb.length === 2) {
|
||||
c++;
|
||||
}
|
||||
try {
|
||||
cb.call(
|
||||
node,
|
||||
arg,
|
||||
function() { node.send.apply(node,arguments) },
|
||||
function(err) {
|
||||
c--;
|
||||
if (c === 0) {
|
||||
doneCount++;
|
||||
if (doneCount === node._expectedDoneCount) {
|
||||
node._complete(arg,err);
|
||||
}
|
||||
}
|
||||
@@ -257,6 +259,9 @@ Node.prototype._removeListener = Node.prototype.removeListener;
|
||||
Node.prototype.removeListener = function(name, listener) {
|
||||
var index;
|
||||
if (name === "input") {
|
||||
if (listener.length === 3) {
|
||||
this._expectedDoneCount--
|
||||
}
|
||||
if (this._inputCallback && this._inputCallback === listener) {
|
||||
// Removing the only callback
|
||||
this._inputCallback = null;
|
||||
|
@@ -384,10 +384,28 @@ var api = module.exports = {
|
||||
}
|
||||
}
|
||||
} else if (nodeType === "global-config") {
|
||||
if (JSON.stringify(savedCredentials.map) !== JSON.stringify(newCreds.map)) {
|
||||
savedCredentials.map = newCreds.map;
|
||||
dirty = true;
|
||||
}
|
||||
savedCredentials.map = savedCredentials.map || {}
|
||||
const existingCredentialKeys = Object.keys(savedCredentials.map)
|
||||
const newCredentialKeys = Object.keys(newCreds?.map || [])
|
||||
existingCredentialKeys.forEach(key => {
|
||||
if (!newCreds.map?.[key]) {
|
||||
// This key doesn't exist in the new credentials list - remove
|
||||
delete savedCredentials.map[key]
|
||||
delete savedCredentials.map[`has_${key}`]
|
||||
dirty = true
|
||||
}
|
||||
})
|
||||
newCredentialKeys.forEach(key => {
|
||||
if (!/^has_/.test(key)) {
|
||||
if (!savedCredentials.map[key] || newCreds.map[key] !== '__PWRD__') {
|
||||
// This key either doesn't exist in current saved, or the
|
||||
// value has been changed
|
||||
savedCredentials.map[key] = newCreds.map[key]
|
||||
savedCredentials.map[`has_${key}`] = newCreds.map[`has_${key}`]
|
||||
dirty = true
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
var dashedType = nodeType.replace(/\s+/g, '-');
|
||||
var definition = credentialsDef[dashedType];
|
||||
|
Reference in New Issue
Block a user