diff --git a/client/src/components/Nav/NewChat.tsx b/client/src/components/Nav/NewChat.tsx index fa2a8aa184..a876f4a810 100644 --- a/client/src/components/Nav/NewChat.tsx +++ b/client/src/components/Nav/NewChat.tsx @@ -1,14 +1,14 @@ -import React from 'react'; +import { useNavigate } from 'react-router-dom'; import { useLocalize, useConversation } from '~/hooks'; export default function NewChat() { const { newConversation } = useConversation(); + const navigate = useNavigate(); const localize = useLocalize(); const clickHandler = () => { - // dispatch(setInputValue('')); - // dispatch(setQuery('')); newConversation(); + navigate('/chat/new'); }; return ( diff --git a/client/src/routes/Chat.tsx b/client/src/routes/Chat.tsx index eb39c987d9..d24ef3e085 100644 --- a/client/src/routes/Chat.tsx +++ b/client/src/routes/Chat.tsx @@ -27,7 +27,7 @@ export default function Chat() { const navigate = useNavigate(); //disabled by default, we only enable it when messagesTree is null - const messagesQuery = useGetMessagesByConvoId(conversationId ?? '', { enabled: false }); + const messagesQuery = useGetMessagesByConvoId(conversationId ?? '', { enabled: !messagesTree }); const getConversationMutation = useGetConversationByIdMutation(conversationId ?? ''); const { data: config } = useGetStartupConfig(); @@ -89,7 +89,8 @@ export default function Chat() { setShouldNavigate(false); } // conversationId (in url) should always follow conversation?.conversationId, unless conversation is null - else if (conversation?.conversationId !== conversationId) { + // messagesTree is null when user navigates, but not on page refresh, so we need to navigate in this case + else if (conversation?.conversationId !== conversationId && !messagesTree) { if (shouldNavigate) { navigate(`/chat/${conversation?.conversationId}`); } else {