1
1
import { useState , useEffect } from 'react' ;
2
- import { useAuthContext } from '~/hooks/AuthContext ' ;
2
+ import { useAuthContext } from '~/hooks' ;
3
3
import { useNavigate , useParams } from 'react-router-dom' ;
4
4
import { useRecoilState , useRecoilValue , useSetRecoilState } from 'recoil' ;
5
5
6
- import Landing from '.. /components/ui/Landing' ;
7
- import Messages from '.. /components/Messages' ;
8
- import TextChat from '.. /components/Input/TextChat' ;
6
+ import Landing from '~ /components/ui/Landing' ;
7
+ import Messages from '~ /components/Messages' ;
8
+ import TextChat from '~ /components/Input/TextChat' ;
9
9
10
10
import store from '~/store' ;
11
11
import {
@@ -27,12 +27,12 @@ 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 } ) ;
31
- const getConversationMutation = useGetConversationByIdMutation ( conversationId ) ;
30
+ const messagesQuery = useGetMessagesByConvoId ( conversationId ?? '' , { enabled : false } ) ;
31
+ const getConversationMutation = useGetConversationByIdMutation ( conversationId ?? '' ) ;
32
32
const { data : config } = useGetStartupConfig ( ) ;
33
33
34
34
useEffect ( ( ) => {
35
- let timeout = setTimeout ( ( ) => {
35
+ const timeout = setTimeout ( ( ) => {
36
36
if ( ! isAuthenticated ) {
37
37
navigate ( '/login' , { replace : true } ) ;
38
38
}
@@ -97,11 +97,12 @@ export default function Chat() {
97
97
}
98
98
}
99
99
document . title = conversation ?. title || config ?. appTitle || 'Chat' ;
100
+ // eslint-disable-next-line react-hooks/exhaustive-deps
100
101
} , [ conversation , conversationId , config ] ) ;
101
102
102
103
useEffect ( ( ) => {
103
104
if ( messagesTree === null && conversation ?. conversationId ) {
104
- messagesQuery . refetch ( conversation ?. conversationId ) ;
105
+ messagesQuery . refetch ( { queryKey : [ conversation ?. conversationId ] } ) ;
105
106
}
106
107
} , [ conversation ?. conversationId , messagesQuery , messagesTree ] ) ;
107
108
@@ -113,6 +114,7 @@ export default function Chat() {
113
114
console . error ( messagesQuery . error ) ;
114
115
setMessages ( null ) ;
115
116
}
117
+ // eslint-disable-next-line react-hooks/exhaustive-deps
116
118
} , [ messagesQuery . data , messagesQuery . isError , setMessages ] ) ;
117
119
118
120
if ( ! isAuthenticated ) {
0 commit comments