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:
parent
b7de1ff3bd
commit
f705995311
1 changed files with 7 additions and 5 deletions
|
|
@ -446,11 +446,13 @@ export function updateNewOutput({ nodes, edges }: updateEdgesHandleIdsType) {
|
||||||
) {
|
) {
|
||||||
const outputTypes = sourceNode.data.node!.output_types;
|
const outputTypes = sourceNode.data.node!.output_types;
|
||||||
// create a new output field for each output type
|
// create a new output field for each output type
|
||||||
sourceNode.data.node!.outputs = outputTypes?.map((type) => ({
|
sourceNode.data.node!.outputs = [
|
||||||
types: [type],
|
{
|
||||||
selected: selected,
|
types: outputTypes ?? [],
|
||||||
name: type,
|
selected: selected,
|
||||||
}));
|
name: outputTypes?.join(" | ") ?? "",
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
edge.sourceHandle = scapedJSONStringfy(newSourceHandle);
|
edge.sourceHandle = scapedJSONStringfy(newSourceHandle);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue