From 19bf71cefc8e76d952add1e53c8761c591d76f18 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:21:00 +0530 Subject: [PATCH] feat(chat-window): only send init msg if ready --- ui/components/ChatWindow.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/components/ChatWindow.tsx b/ui/components/ChatWindow.tsx index b67ca3a..6a56f7e 100644 --- a/ui/components/ChatWindow.tsx +++ b/ui/components/ChatWindow.tsx @@ -473,11 +473,11 @@ const ChatWindow = ({ id }: { id?: string }) => { }; useEffect(() => { - if (isReady && initialMessage) { + if (isReady && initialMessage && ws?.readyState === 1) { sendMessage(initialMessage); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isReady, initialMessage]); + }, [isReady, initialMessage, ws?.readyState]); if (hasError) { return (