🔥 refactor(chatComponent): remove console.log statement and unused imports

The console.log statement in the Chat component has been removed as it is no longer needed. Unused imports have also been removed from the BuildTrigger and Chat components to improve code readability and maintainability.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-15 10:58:21 -03:00
commit d51219583e
2 changed files with 6 additions and 15 deletions

View file

@ -51,13 +51,12 @@ export default function BuildTrigger({
}
async function streamNodeData(flow: FlowType) {
// Step 1: Make a POST request to send the flow data and receive a unique session ID
// Make a POST request to send the flow data and receive a unique session ID
const response = await postBuildInit(flow);
const { flowId } = response.data;
// Step 2: Use the session ID to establish an SSE connection using EventSource
// Use the session ID to establish an SSE connection using EventSource
let validationResults = [];
let finished = false;
const apiUrl = `/api/v1/build/stream/${flowId}`;
const eventSource = new EventSource(apiUrl);
try {
@ -70,7 +69,6 @@ export default function BuildTrigger({
// if the event is the end of the stream, close the connection
if (parsedData.end_of_stream) {
eventSource.close();
return;
}
// Otherwise, process the data
@ -82,12 +80,7 @@ export default function BuildTrigger({
console.error("EventSource failed:", error);
eventSource.close();
};
// Step 3: Wait for the stream to finish
while (!finished) {
await new Promise((resolve) => setTimeout(resolve, 100));
finished = validationResults.length === flow.data.nodes.length;
}
// Step 4: Return true if all nodes are valid, false otherwise
// Return true if all nodes are valid, false otherwise
return validationResults.every((result) => result);
} catch (e) {
console.log(e);

View file

@ -1,11 +1,10 @@
import { Context, useEffect, useRef, useState, useContext } from "react";
import ReactFlow, { useNodes } from "reactflow";
import { ChatMessageType, ChatType } from "../../types/chat";
import { useEffect, useRef, useState } from "react";
import { useNodes } from "reactflow";
import { ChatType } from "../../types/chat";
import ChatTrigger from "./chatTrigger";
import BuildTrigger from "./buildTrigger";
import ChatModal from "../../modals/chatModal";
import _, { set } from "lodash";
import { getBuildStatus } from "../../controllers/API";
import { NodeType } from "../../types/flow";
@ -53,7 +52,6 @@ export default function Chat({ flow }: ChatType) {
JSON.stringify(prevNodes) !== JSON.stringify(currentNodes)
) {
setIsBuilt(false);
console.log("Nodes changed");
}
prevNodesRef.current = currentNodes;