add useEffect to prevent chat lock on fail of onClose method
This commit is contained in:
parent
0c45186fcb
commit
59951a3f68
1 changed files with 10 additions and 2 deletions
|
|
@ -15,7 +15,7 @@ import { sendAllProps } from "../../types/api";
|
||||||
import { ChatMessageType, ChatType } from "../../types/chat";
|
import { ChatMessageType, ChatType } from "../../types/chat";
|
||||||
import ChatInput from "./chatInput";
|
import ChatInput from "./chatInput";
|
||||||
|
|
||||||
import _ from "lodash";
|
import _, { set } from "lodash";
|
||||||
|
|
||||||
export default function ChatModal({
|
export default function ChatModal({
|
||||||
flow,
|
flow,
|
||||||
|
|
@ -100,9 +100,9 @@ export default function ChatModal({
|
||||||
function handleOnClose(event: CloseEvent) {
|
function handleOnClose(event: CloseEvent) {
|
||||||
if (isOpen.current) {
|
if (isOpen.current) {
|
||||||
setErrorData({ title: event.reason });
|
setErrorData({ title: event.reason });
|
||||||
setLockChat(false);
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
connectWS();
|
connectWS();
|
||||||
|
setLockChat(false);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -235,6 +235,13 @@ export default function ChatModal({
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if((ws.current.readyState=== ws.current.CLOSED || ws.current.readyState=== ws.current.CLOSING)){
|
||||||
|
connectWS();
|
||||||
|
setLockChat(false);
|
||||||
|
}
|
||||||
|
},[lockChat]);
|
||||||
|
|
||||||
async function sendAll(data: sendAllProps) {
|
async function sendAll(data: sendAllProps) {
|
||||||
try {
|
try {
|
||||||
if (ws) {
|
if (ws) {
|
||||||
|
|
@ -339,6 +346,7 @@ export default function ChatModal({
|
||||||
function clearChat() {
|
function clearChat() {
|
||||||
setChatHistory([]);
|
setChatHistory([]);
|
||||||
ws.current.send(JSON.stringify({ clear_history: true }));
|
ws.current.send(JSON.stringify({ clear_history: true }));
|
||||||
|
if(lockChat) setLockChat(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setModalOpen(x: boolean) {
|
function setModalOpen(x: boolean) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue