🐛 Fix bug that not all Trigger-Nodes got updated/removed

This commit is contained in:
Jan Oberhauser 2020-01-10 13:38:55 -06:00
parent 83c49ddd21
commit 8b1fe83cc0
2 changed files with 21 additions and 9 deletions

View file

@ -75,17 +75,21 @@ export class ActiveWorkflows {
const triggerNodes = workflow.getTriggerNodes(); const triggerNodes = workflow.getTriggerNodes();
let triggerResponse: ITriggerResponse | undefined; let triggerResponse: ITriggerResponse | undefined;
this.workflowData[id].triggerResponses = [];
for (const triggerNode of triggerNodes) { for (const triggerNode of triggerNodes) {
triggerResponse = await workflow.runTrigger(triggerNode, getTriggerFunctions, additionalData, 'trigger'); triggerResponse = await workflow.runTrigger(triggerNode, getTriggerFunctions, additionalData, 'trigger');
if (triggerResponse !== undefined) { if (triggerResponse !== undefined) {
// If a response was given save it // If a response was given save it
this.workflowData[id].triggerResponse = triggerResponse; this.workflowData[id].triggerResponses!.push(triggerResponse);
} }
} }
const pollNodes = workflow.getPollNodes(); const pollNodes = workflow.getPollNodes();
for (const pollNode of pollNodes) { if (pollNodes.length) {
this.workflowData[id].pollResponse = await this.activatePolling(pollNode, workflow, additionalData, getPollFunctions); this.workflowData[id].pollResponses = [];
for (const pollNode of pollNodes) {
this.workflowData[id].pollResponses!.push(await this.activatePolling(pollNode, workflow, additionalData, getPollFunctions));
}
} }
} }
@ -212,12 +216,20 @@ export class ActiveWorkflows {
const workflowData = this.workflowData[id]; const workflowData = this.workflowData[id];
if (workflowData.triggerResponse && workflowData.triggerResponse.closeFunction) { if (workflowData.triggerResponses) {
await workflowData.triggerResponse.closeFunction(); for (const triggerResponse of workflowData.triggerResponses) {
if (triggerResponse.closeFunction) {
await triggerResponse.closeFunction();
}
}
} }
if (workflowData.pollResponse && workflowData.pollResponse.closeFunction) { if (workflowData.pollResponses) {
await workflowData.pollResponse.closeFunction(); for (const pollResponse of workflowData.pollResponses) {
if (pollResponse.closeFunction) {
await pollResponse.closeFunction();
}
}
} }
delete this.workflowData[id]; delete this.workflowData[id];

View file

@ -123,7 +123,7 @@ export interface INodeInputDataConnections {
export interface IWorkflowData { export interface IWorkflowData {
pollResponse?: IPollResponse; pollResponses?: IPollResponse[];
triggerResponse?: ITriggerResponse; triggerResponses?: ITriggerResponse[];
workflow: Workflow; workflow: Workflow;
} }