From f7059953117633b2e2c6f7845ce794ed713c712d Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Fri, 31 May 2024 10:30:25 -0300 Subject: [PATCH] refactor: Update new output creation logic in reactflowUtils.ts Simplify the logic for creating new output fields in the `updateNewOutput` function of `reactflowUtils.ts`. Instead of mapping over the `outputTypes` array, directly assign a new output field to `sourceNode.data.node!.outputs`. The new output field includes the `outputTypes` as `types`, sets `selected` based on the `selected` variable, and sets `name` as a string representation of `outputTypes` joined with " | ". This change improves the clarity and efficiency of the code. --- src/frontend/src/utils/reactflowUtils.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index afb3db57f..3c3d2f2c0 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -446,11 +446,13 @@ export function updateNewOutput({ nodes, edges }: updateEdgesHandleIdsType) { ) { const outputTypes = sourceNode.data.node!.output_types; // create a new output field for each output type - sourceNode.data.node!.outputs = outputTypes?.map((type) => ({ - types: [type], - selected: selected, - name: type, - })); + sourceNode.data.node!.outputs = [ + { + types: outputTypes ?? [], + selected: selected, + name: outputTypes?.join(" | ") ?? "", + }, + ]; } } edge.sourceHandle = scapedJSONStringfy(newSourceHandle);