1
- import { observer } from ' mobx-react-lite' ;
2
- import React , { useEffect } from ' react' ;
3
- import { format } from ' date-fns' ;
4
- import { useStores } from ' ../../stores/context' ;
5
- import { getRoomArchiveStanza , getPaginatedArchive } from ' ../../xmpp/stanzas' ;
6
- import ChatContainer from ' ../../components/Chat/ChatContainer' ;
7
- import { IMessage , roomListProps } from ' ../../stores/chatStore' ;
8
- import { View } from ' native-base' ;
1
+ import { observer } from " mobx-react-lite" ;
2
+ import React , { useEffect } from " react" ;
3
+ import { format } from " date-fns" ;
4
+ import { useStores } from " ../../stores/context" ;
5
+ import { getRoomArchiveStanza , getPaginatedArchive } from " ../../xmpp/stanzas" ;
6
+ import ChatContainer from " ../../components/Chat/ChatContainer" ;
7
+ import { IMessage , roomListProps } from " ../../stores/chatStore" ;
8
+ import { View } from " native-base" ;
9
9
10
- const ChatScreen = observer ( ( { route} : any ) => {
11
- const { chatStore} = useStores ( ) ;
10
+ const ChatScreen = observer ( ( { route } : any ) => {
11
+ const { chatStore } = useStores ( ) ;
12
12
13
- const { chatJid, chatName} = route . params ;
14
- const room :roomListProps = chatStore . roomList . find ( item => item . jid === chatJid ) || {
15
- avatar :"" ,
16
- counter :0 ,
17
- createdAt :"" ,
18
- jid :chatJid ,
19
- lastUserName :"" ,
20
- lastUserText :"" ,
21
- name :chatName ?chatName :'' ,
22
- participants :0 ,
23
- isFavourite :false ,
24
- muted :false ,
25
- priority :0 ,
26
- roomBackground :"" ,
27
- roomBackgroundIndex :0 ,
28
- roomThumbnail :""
13
+ const { chatJid, chatName } = route . params ;
14
+ const room : roomListProps = chatStore . roomList . find (
15
+ ( item ) => item . jid === chatJid
16
+ ) || {
17
+ avatar : "" ,
18
+ counter : 0 ,
19
+ createdAt : "" ,
20
+ jid : chatJid ,
21
+ lastUserName : "" ,
22
+ lastUserText : "" ,
23
+ name : chatName ? chatName : "" ,
24
+ participants : 0 ,
25
+ isFavourite : false ,
26
+ muted : false ,
27
+ priority : 0 ,
28
+ roomBackground : "" ,
29
+ roomBackgroundIndex : 0 ,
30
+ roomThumbnail : "" ,
29
31
} ;
30
32
const messages = chatStore . messages
31
33
. filter ( ( item : IMessage ) => {
@@ -66,7 +68,8 @@ const ChatScreen = observer(({route}: any) => {
66
68
lastUserText : lastMessage ?. text ,
67
69
lastUserName : lastMessage ?. user ?. name ,
68
70
lastMessageTime :
69
- lastMessage ?. createdAt && format ( lastMessage ?. createdAt as Date , 'hh:mm' ) ,
71
+ lastMessage ?. createdAt &&
72
+ format ( new Date ( lastMessage ?. createdAt ) , "hh:mm" ) ,
70
73
} ) ;
71
74
} , [ ! ! messages ] ) ;
72
75
@@ -79,7 +82,7 @@ const ChatScreen = observer(({route}: any) => {
79
82
} ;
80
83
81
84
return (
82
- < View testID = ' ChatScreen' >
85
+ < View testID = " ChatScreen" >
83
86
< ChatContainer
84
87
containerType = "main"
85
88
roomDetails = { room }
@@ -90,4 +93,4 @@ const ChatScreen = observer(({route}: any) => {
90
93
) ;
91
94
} ) ;
92
95
93
- export default ChatScreen ;
96
+ export default ChatScreen ;
0 commit comments