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 a1c902f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 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 @@ -270,7 +268,6 @@ export const RunGraphFlow: React.FC<{
const { fitView } = useReactFlow();

useEffect(() => {
const id: Timer | null = null;
if (shouldLayout) {
doNodeLayout(setNodes, setEdges);
setTimeout(() => {
Expand Down Expand Up @@ -303,7 +300,7 @@ export const RunGraphFlow: React.FC<{
};
})
);
listenToGraphTasks(graph, setNodes, edges, setEdges);
listenToGraphTasks(graph, setNodes, setEdges);
}
}, [graph, setNodes, setEdges, graphRef.current]);

Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,5 @@ export function computeLayout(
}
}

return returnNodes.toReversed().map((node) => ({ ...node }));
return returnNodes.reverse().map((node) => ({ ...node }));
}

0 comments on commit a1c902f

Please sign in to comment.