mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
fix(Chat): correctly render when refreshing/visiting a conversation page (#1037)
This commit is contained in:
parent
b3aac97710
commit
495ac1b36d
2 changed files with 6 additions and 5 deletions
|
|
@ -1,14 +1,14 @@
|
||||||
import React from 'react';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useLocalize, useConversation } from '~/hooks';
|
import { useLocalize, useConversation } from '~/hooks';
|
||||||
|
|
||||||
export default function NewChat() {
|
export default function NewChat() {
|
||||||
const { newConversation } = useConversation();
|
const { newConversation } = useConversation();
|
||||||
|
const navigate = useNavigate();
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
|
|
||||||
const clickHandler = () => {
|
const clickHandler = () => {
|
||||||
// dispatch(setInputValue(''));
|
|
||||||
// dispatch(setQuery(''));
|
|
||||||
newConversation();
|
newConversation();
|
||||||
|
navigate('/chat/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export default function Chat() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
//disabled by default, we only enable it when messagesTree is null
|
//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 getConversationMutation = useGetConversationByIdMutation(conversationId ?? '');
|
||||||
const { data: config } = useGetStartupConfig();
|
const { data: config } = useGetStartupConfig();
|
||||||
|
|
||||||
|
|
@ -89,7 +89,8 @@ export default function Chat() {
|
||||||
setShouldNavigate(false);
|
setShouldNavigate(false);
|
||||||
}
|
}
|
||||||
// conversationId (in url) should always follow conversation?.conversationId, unless conversation is null
|
// 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) {
|
if (shouldNavigate) {
|
||||||
navigate(`/chat/${conversation?.conversationId}`);
|
navigate(`/chat/${conversation?.conversationId}`);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue