new lock chat implemented
This commit is contained in:
parent
be5b7822d7
commit
f36fe34831
3 changed files with 17 additions and 25 deletions
|
|
@ -22,8 +22,6 @@ const TabsContextInitialValue: TabsContextType = {
|
||||||
incrementNodeId: () => 0,
|
incrementNodeId: () => 0,
|
||||||
downloadFlow: (flow: FlowType) => {},
|
downloadFlow: (flow: FlowType) => {},
|
||||||
uploadFlow: () => {},
|
uploadFlow: () => {},
|
||||||
lockChat: false,
|
|
||||||
setLockChat: (prevState: boolean) => {},
|
|
||||||
hardReset: () => {},
|
hardReset: () => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -192,8 +190,6 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
value={{
|
value={{
|
||||||
save,
|
save,
|
||||||
hardReset,
|
hardReset,
|
||||||
lockChat,
|
|
||||||
setLockChat,
|
|
||||||
tabIndex,
|
tabIndex,
|
||||||
setTabIndex,
|
setTabIndex,
|
||||||
flows,
|
flows,
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,13 @@ export default function ChatModal({
|
||||||
setOpen: Function;
|
setOpen: Function;
|
||||||
flow: FlowType;
|
flow: FlowType;
|
||||||
}) {
|
}) {
|
||||||
const { updateFlow, lockChat, setLockChat } = useContext(TabsContext);
|
const { updateFlow } = useContext(TabsContext);
|
||||||
const [chatValue, setChatValue] = useState("");
|
const [chatValue, setChatValue] = useState("");
|
||||||
const [chatHistory, setChatHistory] = useState<ChatMessageType[]>([]);
|
const [chatHistory, setChatHistory] = useState<ChatMessageType[]>([]);
|
||||||
const { reactFlowInstance } = useContext(typesContext);
|
const { reactFlowInstance } = useContext(typesContext);
|
||||||
const { setErrorData, setNoticeData } = useContext(alertContext);
|
const { setErrorData, setNoticeData } = useContext(alertContext);
|
||||||
const [ws, setWs] = useState<WebSocket | null>(null);
|
const [ws, setWs] = useState<WebSocket | null>(null);
|
||||||
|
const [lockChat, setLockChat] = useState(false);
|
||||||
const addChatHistory = (
|
const addChatHistory = (
|
||||||
message: string,
|
message: string,
|
||||||
isSend: boolean,
|
isSend: boolean,
|
||||||
|
|
@ -79,6 +80,7 @@ export default function ChatModal({
|
||||||
}
|
}
|
||||||
if (data.type === "end") {
|
if (data.type === "end") {
|
||||||
addChatHistory(data.message, false, data.intermediate_steps);
|
addChatHistory(data.message, false, data.intermediate_steps);
|
||||||
|
setLockChat(false)
|
||||||
}
|
}
|
||||||
// Do something with the data received from the WebSocket
|
// Do something with the data received from the WebSocket
|
||||||
};
|
};
|
||||||
|
|
@ -162,11 +164,7 @@ export default function ChatModal({
|
||||||
chatHistory,
|
chatHistory,
|
||||||
name: flow.name,
|
name: flow.name,
|
||||||
description: flow.description,
|
description: flow.description,
|
||||||
})
|
}).catch((error) => {
|
||||||
.then(() => {
|
|
||||||
setLockChat(false);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
setErrorData({
|
setErrorData({
|
||||||
title: error.message ?? "Unknown Error",
|
title: error.message ?? "Unknown Error",
|
||||||
list: [error.response.data.detail],
|
list: [error.response.data.detail],
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,5 @@ export type TabsContextType = {
|
||||||
incrementNodeId: () => number;
|
incrementNodeId: () => number;
|
||||||
downloadFlow: (flow:FlowType) => void;
|
downloadFlow: (flow:FlowType) => void;
|
||||||
uploadFlow: () => void;
|
uploadFlow: () => void;
|
||||||
lockChat:boolean;
|
|
||||||
setLockChat:(prevState:boolean)=>void;
|
|
||||||
hardReset:()=>void;
|
hardReset:()=>void;
|
||||||
};
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue