Skip to content

Commit

Permalink
[web] fix: post merge cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sroussey committed Apr 11, 2024
1 parent 841aad1 commit 13a4dca
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/web/src/RunGraphFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ function doNodeLayout(
function listenToTask(
task: Task,
setNodes: Dispatch<SetStateAction<Node<TurboNodeData>[]>>,
edges: Edge[],
setEdges: Dispatch<SetStateAction<Edge[]>>
) {
task.on("progress", (progress, progressText) => {
Expand Down Expand Up @@ -209,7 +208,7 @@ function listenToTask(
);
});
if (task.isCompound) {
listenToGraphTasks(task.subGraph, setNodes, edges, setEdges);
listenToGraphTasks(task.subGraph, setNodes, setEdges);
task.on("regenerate", () => {
// console.log("Node regenerated", task.config.id);
setNodes((nodes: Node<TurboNodeData>[]) => {
Expand All @@ -223,7 +222,7 @@ function listenToTask(
connectable: false,
}) as Node<TurboNodeData>
);
listenToGraphTasks(task.subGraph, setNodes, edges, setEdges);
listenToGraphTasks(task.subGraph, setNodes, setEdges);
let returnNodes = nodes.filter((n) => n.parentId !== task.config.id); // remove old children
returnNodes = [...returnNodes, ...children]; // add new children
returnNodes = sortNodes(returnNodes); // sort all nodes (parent, children, parent, children, ...)
Expand All @@ -236,12 +235,11 @@ function listenToTask(
function listenToGraphTasks(
graph: TaskGraph,
setNodes: Dispatch<SetStateAction<Node<TurboNodeData>[]>>,
edges: Edge[],
setEdges: Dispatch<SetStateAction<Edge[]>>
) {
const nodes = graph.getNodes();
for (const node of nodes) {
listenToTask(node, setNodes, edges, setEdges);
listenToTask(node, setNodes, setEdges);
}
}

Expand Down Expand Up @@ -303,7 +301,7 @@ export const RunGraphFlow: React.FC<{
};
})
);
listenToGraphTasks(graph, setNodes, edges, setEdges);
listenToGraphTasks(graph, setNodes, setEdges);
}
}, [graph, setNodes, setEdges, graphRef.current]);

Expand Down

0 comments on commit 13a4dca

Please sign in to comment.