From 92cba01e52b16db6497ad5474c6bff93e14bfd3c Mon Sep 17 00:00:00 2001 From: projectmoon Date: Tue, 30 Jul 2024 19:45:20 +0200 Subject: [PATCH] Do not set websocket to null if in error state. --- ui/components/ChatWindow.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/components/ChatWindow.tsx b/ui/components/ChatWindow.tsx index 8e1feff..9bc7ae6 100644 --- a/ui/components/ChatWindow.tsx +++ b/ui/components/ChatWindow.tsx @@ -215,7 +215,9 @@ const useSocket = ( ws.onclose = () => { clearTimeout(timeoutId); - setWs(null); // forces websocket to reopen when needed. + if (!hasError) { + setWs(null); // forces websocket to reopen when needed. + } console.log('[DEBUG] closed'); }; @@ -306,6 +308,7 @@ const ChatWindow = ({ id }: { id?: string }) => { process.env.NEXT_PUBLIC_WS_URL!, setIsWSReady, setHasError, + hasError ); const [loading, setLoading] = useState(false);