Skip to content

Commit

Permalink
feat: merge all data from all workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Siykt committed Oct 17, 2023
1 parent a0af454 commit 5b6d229
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/workflowEngine/WorkflowEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 9 additions & 8 deletions src/workflowEngine/blocksHandler/handlerExecuteWorkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5b6d229

Please sign in to comment.