From 5b6d2297440b6622c525b01aec9158d7c7aed1af Mon Sep 17 00:00:00 2001 From: siykt Date: Tue, 17 Oct 2023 14:49:30 +0800 Subject: [PATCH] feat: merge all data from all workflows --- src/workflowEngine/WorkflowEngine.js | 6 ++++++ .../blocksHandler/handlerExecuteWorkflow.js | 17 +++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/workflowEngine/WorkflowEngine.js b/src/workflowEngine/WorkflowEngine.js index 0af5017bb..487101edd 100644 --- a/src/workflowEngine/WorkflowEngine.js +++ b/src/workflowEngine/WorkflowEngine.js @@ -480,6 +480,12 @@ class WorkflowEngine { const { table, variables } = this.referenceData; const tableId = this.workflow.connectedTable; + // Merge all table and variables from all workflows + Object.values(this.referenceData.workflow).forEach((data) => { + Object.assign(table, data.table); + Object.assign(variables, data.variables); + }); + await dbStorage.transaction( 'rw', dbStorage.tablesItems, diff --git a/src/workflowEngine/blocksHandler/handlerExecuteWorkflow.js b/src/workflowEngine/blocksHandler/handlerExecuteWorkflow.js index 00662b206..9e249e43c 100644 --- a/src/workflowEngine/blocksHandler/handlerExecuteWorkflow.js +++ b/src/workflowEngine/blocksHandler/handlerExecuteWorkflow.js @@ -2,6 +2,7 @@ import browser from 'webextension-polyfill'; import { isWhitespace, parseJSON } from '@/utils/helper'; import decryptFlow, { getWorkflowPass } from '@/utils/decryptFlow'; import convertWorkflowData from '@/utils/convertWorkflowData'; +import { nanoid } from 'nanoid'; import WorkflowEngine from '../WorkflowEngine'; function workflowListener(workflow, options) { @@ -115,14 +116,14 @@ async function executeWorkflow({ id: blockId, data }, { refData }) { this.childWorkflowId = engine.id; }, onDestroyed: (engine) => { - if (data.executeId) { - const { variables, table } = engine.referenceData; - - this.engine.referenceData.workflow[data.executeId] = { - table, - variables, - }; - } + const { variables, table } = engine.referenceData; + + this.engine.referenceData.workflow[ + data.executeId || `${engine.id}-${nanoid(8)}` + ] = { + table, + variables, + }; }, }, states: this.engine.states,