From f619c5419bbcac274597b56f27e8f6cdf427f381 Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Thu, 17 Nov 2022 17:14:22 +0200 Subject: [PATCH] fix: store copy of workflow in workflowsById to prevent node data bugs --- packages/editor-ui/src/stores/workflows.ts | 6 +++++- packages/editor-ui/src/views/NodeView.vue | 15 +-------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/editor-ui/src/stores/workflows.ts b/packages/editor-ui/src/stores/workflows.ts index f1764da91de4e..6eb912321efc9 100644 --- a/packages/editor-ui/src/stores/workflows.ts +++ b/packages/editor-ui/src/stores/workflows.ts @@ -24,6 +24,7 @@ import { } from "@/Interface"; import {defineStore} from "pinia"; import { + deepCopy, IConnection, IConnections, IDataObject, @@ -334,7 +335,10 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, { }, addWorkflow(workflow: IWorkflowDb) : void { - Vue.set(this.workflowsById, workflow.id, workflow); + Vue.set(this.workflowsById, workflow.id, { + ...this.workflowsById[workflow.id], + ...deepCopy(workflow), + }); }, setWorkflowActive(workflowId: string): void { diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index fdc2243cf32d2..ca0aa3249560f 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -834,6 +834,7 @@ export default mixins( ); } + this.workflowsStore.addWorkflow(data); this.workflowsStore.setActive(data.active || false); this.workflowsStore.setWorkflowId(workflowId); this.workflowsStore.setWorkflowName({ newName: data.name, setStateDirty: false }); @@ -841,20 +842,6 @@ export default mixins( this.workflowsStore.setWorkflowPinData(data.pinData || {}); this.workflowsStore.setWorkflowHash(data.hash); - this.workflowsStore.addWorkflow({ - id: data.id, - name: data.name, - ownedBy: data.ownedBy, - sharedWith: data.sharedWith, - tags: data.tags || [], - active: data.active, - createdAt: data.createdAt, - updatedAt: data.updatedAt, - nodes: data.nodes, - connections: data.connections, - hash: '', - }); - if (data.ownedBy) { this.workflowsEEStore.setWorkflowOwnedBy({ workflowId: data.id,