fixed lockChat logic
This commit is contained in:
parent
56d97e7c7f
commit
5d94b5cd9c
1 changed files with 10 additions and 15 deletions
|
|
@ -112,9 +112,12 @@ export default function ChatModal({
|
|||
// Do something with the data received from the WebSocket
|
||||
};
|
||||
newWs.onclose = (e) => {
|
||||
console.log(e.code);
|
||||
console.log("close");
|
||||
setLockChat(false);
|
||||
};
|
||||
newWs.onerror = (e) => {
|
||||
window.alert("error");
|
||||
};
|
||||
setWs(newWs);
|
||||
|
||||
return () => {
|
||||
|
|
@ -132,6 +135,12 @@ export default function ChatModal({
|
|||
if (ref.current) ref.current.scrollIntoView({ behavior: "smooth" });
|
||||
}, [chatHistory]);
|
||||
|
||||
useEffect(() => {
|
||||
if (ws &&ws.readyState===ws.CLOSED) {
|
||||
setLockChat(false);
|
||||
}
|
||||
}, [lockChat]);
|
||||
|
||||
function validateNode(n: NodeType): Array<string> {
|
||||
if (!n.data?.node?.template || !Object.keys(n.data.node.template)) {
|
||||
setNoticeData({
|
||||
|
|
@ -195,20 +204,6 @@ export default function ChatModal({
|
|||
chatHistory,
|
||||
name: flow.name,
|
||||
description: flow.description,
|
||||
}).catch((error) => {
|
||||
setErrorData({
|
||||
title: error.message ?? "Unknown Error",
|
||||
list: [error.response.data.detail],
|
||||
});
|
||||
setLockChat(false);
|
||||
let lastMessage;
|
||||
setChatHistory((chatHistory) => {
|
||||
let newChat = chatHistory;
|
||||
|
||||
lastMessage = newChat.pop().message;
|
||||
return newChat;
|
||||
});
|
||||
setChatValue(lastMessage);
|
||||
});
|
||||
} else {
|
||||
setErrorData({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue