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.
This commit is contained in:
ogabrielluiz 2024-05-31 10:30:25 -03:00
commit f705995311

View file

@ -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);