File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 1
- import React from 'react' ;
1
+ import { useNavigate } from 'react-router-dom ' ;
2
2
import { useLocalize , useConversation } from '~/hooks' ;
3
3
4
4
export default function NewChat ( ) {
5
5
const { newConversation } = useConversation ( ) ;
6
+ const navigate = useNavigate ( ) ;
6
7
const localize = useLocalize ( ) ;
7
8
8
9
const clickHandler = ( ) => {
9
- // dispatch(setInputValue(''));
10
- // dispatch(setQuery(''));
11
10
newConversation ( ) ;
11
+ navigate ( '/chat/new' ) ;
12
12
} ;
13
13
14
14
return (
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export default function Chat() {
27
27
const navigate = useNavigate ( ) ;
28
28
29
29
//disabled by default, we only enable it when messagesTree is null
30
- const messagesQuery = useGetMessagesByConvoId ( conversationId ?? '' , { enabled : false } ) ;
30
+ const messagesQuery = useGetMessagesByConvoId ( conversationId ?? '' , { enabled : ! messagesTree } ) ;
31
31
const getConversationMutation = useGetConversationByIdMutation ( conversationId ?? '' ) ;
32
32
const { data : config } = useGetStartupConfig ( ) ;
33
33
@@ -89,7 +89,8 @@ export default function Chat() {
89
89
setShouldNavigate ( false ) ;
90
90
}
91
91
// conversationId (in url) should always follow conversation?.conversationId, unless conversation is null
92
- else if ( conversation ?. conversationId !== conversationId ) {
92
+ // messagesTree is null when user navigates, but not on page refresh, so we need to navigate in this case
93
+ else if ( conversation ?. conversationId !== conversationId && ! messagesTree ) {
93
94
if ( shouldNavigate ) {
94
95
navigate ( `/chat/${ conversation ?. conversationId } ` ) ;
95
96
} else {
You can’t perform that action at this time.
0 commit comments