feat: use store-provided methods

This commit is contained in:
Alex Grozav 2024-11-07 16:12:23 +02:00
parent 5d7ab5b90b
commit 0c5a057536
2 changed files with 10 additions and 18 deletions

View file

@ -1378,20 +1378,14 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
}
async function initializeWorkspace(data: IWorkflowDb) {
// Set workflow data
workflowHelpers.initState(data);
workflowsStore.workflow.nodes = data.nodes;
workflowsStore.workflow.connections = data.connections;
void nextTick(() => {
workflowsStore.workflow.nodes.forEach((node) => {
workflowsStore.setNodeMetadata(node.name, { pristine: true });
nodeHelpers.matchCredentials(node);
nodeHelpers.updateNodeParameterIssues(node);
nodeHelpers.updateNodeCredentialIssues(node);
nodeHelpers.updateNodeInputIssues(node);
});
data.nodes.forEach((node) => {
nodeHelpers.matchCredentials(node);
});
workflowsStore.setNodes(data.nodes);
workflowsStore.setConnections(data.connections);
}
/**

View file

@ -1046,6 +1046,10 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
function setNodes(nodes: INodeUi[]): void {
workflow.value.nodes = nodes;
nodeMetadata.value = nodes.reduce<NodeMetadataMap>((acc, node) => {
acc[node.name] = { pristine: true };
return acc;
}, {});
}
function setConnections(connections: IConnections): void {
@ -1109,10 +1113,9 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
}
workflow.value.nodes.push(nodeData);
// Init node metadata
if (!nodeMetadata.value[nodeData.name]) {
setNodeMetadata(nodeData.name, {} as INodeMetadata);
nodeMetadata.value[nodeData.name] = {} as INodeMetadata;
}
}
@ -1558,10 +1561,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
return url.toString();
}
function setNodeMetadata(nodeName: string, metadata: INodeMetadata): void {
nodeMetadata.value[nodeName] = metadata;
}
function setNodePristine(nodeName: string, isPristine: boolean): void {
nodeMetadata.value[nodeName].pristine = isPristine;
}
@ -1754,7 +1753,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
deleteExecution,
addToCurrentExecutions,
getBinaryUrl,
setNodeMetadata,
setNodePristine,
resetChatMessages,
appendChatMessage,