Add deleteFlowPool function and useFlowsManagerStore in newChatView

This commit is contained in:
anovazzi1 2024-01-31 15:32:58 -03:00
commit f7766118e8
2 changed files with 16 additions and 2 deletions

View file

@ -1,8 +1,10 @@
import { cloneDeep } from "lodash";
import { useEffect, useRef, useState } from "react";
import IconComponent from "../../components/genericIconComponent";
import { deleteFlowPool } from "../../controllers/API";
import useAlertStore from "../../stores/alertStore";
import useFlowStore from "../../stores/flowStore";
import useFlowsManagerStore from "../../stores/flowsManagerStore";
import { sendAllProps } from "../../types/api";
import {
ChatMessageType,
@ -29,6 +31,7 @@ export default function newChatView(): JSX.Element {
CleanFlowPool,
} = useFlowStore();
const { setErrorData } = useAlertStore();
const currentFlowId = useFlowsManagerStore((state) => state.currentFlowId);
const [lockChat, setLockChat] = useState(false);
const messagesRef = useRef<HTMLDivElement | null>(null);
@ -112,7 +115,9 @@ export default function newChatView(): JSX.Element {
}
function clearChat(): void {
setChatHistory([]);
CleanFlowPool();
deleteFlowPool(currentFlowId).then((_) => {
CleanFlowPool();
});
//TODO tell backend to clear chat session
if (lockChat) setLockChat(false);
}

View file

@ -879,8 +879,17 @@ export async function getFlowPool({
nodeId?: string;
}): Promise<AxiosResponse<FlowPoolType>> {
const config = {};
config["params"] = { flow_id: flowId };
if (nodeId) {
config["params"] = { nodeId };
}
return await api.get(`${BASE_URL_API}flow_pool/${flowId}`, config);
return await api.get(`${BASE_URL_API}monitor/builds`, config);
}
export async function deleteFlowPool(
flowId: string
): Promise<AxiosResponse<any>> {
const config = {};
config["params"] = { flow_id: flowId };
return await api.delete(`${BASE_URL_API}monitor/builds`, config);
}