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
|
// Do something with the data received from the WebSocket
|
||||||
};
|
};
|
||||||
newWs.onclose = (e) => {
|
newWs.onclose = (e) => {
|
||||||
console.log(e.code);
|
console.log("close");
|
||||||
setLockChat(false);
|
setLockChat(false);
|
||||||
};
|
};
|
||||||
|
newWs.onerror = (e) => {
|
||||||
|
window.alert("error");
|
||||||
|
};
|
||||||
setWs(newWs);
|
setWs(newWs);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|
@ -132,6 +135,12 @@ export default function ChatModal({
|
||||||
if (ref.current) ref.current.scrollIntoView({ behavior: "smooth" });
|
if (ref.current) ref.current.scrollIntoView({ behavior: "smooth" });
|
||||||
}, [chatHistory]);
|
}, [chatHistory]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (ws &&ws.readyState===ws.CLOSED) {
|
||||||
|
setLockChat(false);
|
||||||
|
}
|
||||||
|
}, [lockChat]);
|
||||||
|
|
||||||
function validateNode(n: NodeType): Array<string> {
|
function validateNode(n: NodeType): Array<string> {
|
||||||
if (!n.data?.node?.template || !Object.keys(n.data.node.template)) {
|
if (!n.data?.node?.template || !Object.keys(n.data.node.template)) {
|
||||||
setNoticeData({
|
setNoticeData({
|
||||||
|
|
@ -195,20 +204,6 @@ export default function ChatModal({
|
||||||
chatHistory,
|
chatHistory,
|
||||||
name: flow.name,
|
name: flow.name,
|
||||||
description: flow.description,
|
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 {
|
} else {
|
||||||
setErrorData({
|
setErrorData({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue