fix(core): Fix issue that "closeFunction" got called twice

This commit is contained in:
Jan Oberhauser 2022-05-27 16:05:16 +02:00
parent 02cdec1416
commit 1910299a88

View file

@ -134,22 +134,24 @@ export class ActiveWorkflowRunner {
* @memberof ActiveWorkflowRunner * @memberof ActiveWorkflowRunner
*/ */
async removeAll(): Promise<void> { async removeAll(): Promise<void> {
const activeWorkflowId: string[] = []; let activeWorkflowIds: string[] = [];
Logger.verbose('Call to remove all active workflows received (removeAll)'); Logger.verbose('Call to remove all active workflows received (removeAll)');
if (this.activeWorkflows !== null) { if (this.activeWorkflows !== null) {
// TODO: This should be renamed! activeWorkflowIds.push.apply(activeWorkflowIds, this.activeWorkflows.allActiveWorkflows());
activeWorkflowId.push.apply(activeWorkflowId, this.activeWorkflows.allActiveWorkflows());
} }
const activeWorkflows = await this.getActiveWorkflows(); const activeWorkflows = await this.getActiveWorkflows();
activeWorkflowId.push.apply( activeWorkflowIds = [
activeWorkflowId, ...activeWorkflowIds,
activeWorkflows.map((workflow) => workflow.id), ...activeWorkflows.map((workflow) => workflow.id.toString()),
); ];
// Make sure IDs are unique
activeWorkflowIds = Array.from(new Set(activeWorkflowIds));
const removePromises = []; const removePromises = [];
for (const workflowId of activeWorkflowId) { for (const workflowId of activeWorkflowIds) {
removePromises.push(this.remove(workflowId)); removePromises.push(this.remove(workflowId));
} }