Skip to content

Commit 6355560

Browse files
committed
fix: move for _wf and _node computation in single loop
1 parent a258747 commit 6355560

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/components/workflowEditor/workflowEditor.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,19 @@ class WorkflowEdit extends Component<WorkflowEditProps, WorkflowEditState> {
400400
// and compute the maximum y of the bufferNodes and if there are downstreams > 1 then also for maxY, we will check maxY using node.y and depth
401401
if (selectedNode) {
402402
// would check if selectedNode.type and selectedNode.id is same as node.id and node.type
403-
const _wf = this.state.workflows.find((wf) =>
404-
wf.nodes.find(
405-
(wfNode) => String(wfNode.id) === String(selectedNode.id) && wfNode.type === selectedNode.nodeType,
406-
),
407-
)
408-
const _node = _wf?.nodes.find(
409-
(wfNode) => String(wfNode.id) === String(selectedNode.id) && wfNode.type === selectedNode.nodeType,
410-
)
403+
let _wf = null
404+
let _node = null
405+
this.state.workflows.forEach((wf) => {
406+
if (!_wf) {
407+
_node = wf.nodes?.find(
408+
(wfNode) =>
409+
String(wfNode.id) === String(selectedNode.id) && wfNode.type === selectedNode.nodeType,
410+
)
411+
if (_node) {
412+
_wf = wf
413+
}
414+
}
415+
})
411416
if (_node) {
412417
const { downstreamNodes } = getAllChildDownstreams(_node, _wf)
413418
const firstLevelDownstreamMaxY = getMaxYFromFirstLevelDownstream(_node, _wf)

0 commit comments

Comments
 (0)