From e57b88cdfdeb6959935f61101a53893cb15c5b42 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 7 Jun 2024 23:57:51 +0530 Subject: [PATCH] feat: if match found, add new action into matched rule --- .../src/workflow-management/classes/Generator.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/server/src/workflow-management/classes/Generator.ts b/server/src/workflow-management/classes/Generator.ts index 51b13942..27429755 100644 --- a/server/src/workflow-management/classes/Generator.ts +++ b/server/src/workflow-management/classes/Generator.ts @@ -130,7 +130,20 @@ export class WorkflowGenerator { let matched = false; // validate if a pair with the same where conditions is already present in the workflow if (pair.where.selectors && pair.where.selectors[0]) { - + const match = selectorAlreadyInWorkflow(pair.where.selectors[0], this.workflowRecord.workflow); + if (match) { + // if a match of where conditions is found, the new action is added into the matched rule + const matchedIndex = this.workflowRecord.workflow.indexOf(match); + if (pair.what[0].action !== 'waitForLoadState' && pair.what[0].action !== 'press') { + pair.what.push({ + action: 'waitForLoadState', + args: ['networkidle'], + }) + } + this.workflowRecord.workflow[matchedIndex].what = this.workflowRecord.workflow[matchedIndex].what.concat(pair.what); + logger.log('info', `Pushed ${JSON.stringify(this.workflowRecord.workflow[matchedIndex])} to workflow pair`); + matched = true; + } } };