Refactor variable name in buildUtils.ts

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-02-20 20:57:12 -03:00
commit c7ae2a5eae

View file

@ -25,7 +25,7 @@ export async function buildVertices({
}: BuildVerticesParams) { }: BuildVerticesParams) {
let orderResponse = await getVerticesOrder(flowId, nodeId); let orderResponse = await getVerticesOrder(flowId, nodeId);
let verticesOrder: Array<Array<string>> = orderResponse.data.ids; let verticesOrder: Array<Array<string>> = orderResponse.data.ids;
let vertices: Array<Array<string>> = []; let vertices_layers: Array<Array<string>> = [];
if (nodeId) { if (nodeId) {
for (let i = 0; i < verticesOrder.length; i += 1) { for (let i = 0; i < verticesOrder.length; i += 1) {
@ -35,27 +35,25 @@ export async function buildVertices({
// If there's a nodeId, we want to run just that component and not the entire layer // If there's a nodeId, we want to run just that component and not the entire layer
// because a layer contains dependencies for the next layer // because a layer contains dependencies for the next layer
// and we are stopping at the layer that contains the nodeId // and we are stopping at the layer that contains the nodeId
vertices.push([innerArray[idIndex]]); vertices_layers.push([innerArray[idIndex]]);
break; // Stop searching after finding the first occurrence break; // Stop searching after finding the first occurrence
} }
// If the targetId is not found, include the entire inner array // If the targetId is not found, include the entire inner array
vertices.push(innerArray); vertices_layers.push(innerArray);
} }
} else { } else {
vertices = verticesOrder; vertices_layers = verticesOrder;
} }
const verticesIds = vertices.flatMap((v) => v); const verticesIds = vertices_layers.flatMap((v) => v);
useFlowStore.getState().updateBuildStatus(verticesIds, BuildStatus.TO_BUILD); useFlowStore.getState().updateBuildStatus(verticesIds, BuildStatus.TO_BUILD);
useFlowStore.getState().updateVerticesBuild(verticesIds); useFlowStore.getState().updateVerticesBuild(verticesIds);
// Set each vertex state to building // Set each vertex state to building
const buildResults: Array<boolean> = []; const buildResults: Array<boolean> = [];
// by not using Promise.all, we can update the UI as we build each vertex for (const layer of vertices_layers) {
// and not wait for all of them to finish if (onBuildStart) onBuildStart(layer);
for (let i = 0; i < vertices.length; i += 1) { for (const id of layer) {
if (onBuildStart) onBuildStart(vertices[i]);
for (const id of vertices[i]) {
await buildVertex({ await buildVertex({
flowId, flowId,
id, id,