@@ -367,11 +367,11 @@ export const CometChatConversations = (props: ConversationInterface) => {
367367 const userEventHandler = ( ...args : any [ ] ) => {
368368 const { uid, blockedByMe, status } = args [ 0 ] ;
369369 if ( ! blockedByMe ) {
370- let item : CometChat . Conversation | any = conversationListRef . current ?. getListItem ( `${ uid } _user_${ loggedInUser . current ?. uid } ` ) || conversationListRef . current ?. getListItem ( `${ loggedInUser . current ?. uid } _user_${ uid } ` ) ;
370+ let item : CometChat . Conversation | any = conversationListRef . current ?. getListItem ( `${ uid } _user_${ loggedInUser . current ?. uid } ` ) as unknown as CometChat . Conversation || conversationListRef . current ?. getListItem ( `${ loggedInUser . current ?. uid } _user_${ uid } ` ) as unknown as CometChat . Conversation ;
371371 if ( item ) {
372372 let updatedConversation = CommonUtils . clone ( item ) ;
373373 updatedConversation . setConversationWith ( args [ 0 ] ) ;
374- conversationListRef . current . updateList ( updatedConversation ) ;
374+ conversationListRef . current ? .updateList ( updatedConversation ) ;
375375 }
376376 }
377377 }
@@ -566,18 +566,18 @@ export const CometChatConversations = (props: ConversationInterface) => {
566566 }
567567
568568 const updateMessageReceipt = ( receipt : CometChat . MessageReceipt ) => {
569- const conv : CometChat . Conversation =
569+ const conv : CometChat . Conversation | boolean =
570570 receipt ?. getReceiverType ( ) === ReceiverTypeConstants . user
571- ? conversationListRef . current . getListItem (
571+ ? conversationListRef . current ? .getListItem (
572572 `${ receipt ?. getReceiver ( ) } _user_${ receipt ?. getSender ( ) . getUid ( ) } `
573- ) ||
574- conversationListRef . current . getListItem (
573+ ) as unknown as CometChat . Conversation ||
574+ conversationListRef . current ? .getListItem (
575575 `${ receipt ?. getSender ( ) ?. getUid ( ) } _user_${ receipt ?. getReceiver ( ) } `
576- )
576+ ) as unknown as CometChat . Conversation
577577 : [ receipt . RECEIPT_TYPE . DELIVERED_TO_ALL_RECEIPT , receipt . RECEIPT_TYPE . READ_BY_ALL_RECEIPT ] . includes ( receipt ?. getReceiptType ( ) ) &&
578- conversationListRef . current . getListItem (
578+ conversationListRef . current ? .getListItem (
579579 `group_${ receipt ?. getReceiver ( ) } `
580- ) ;
580+ ) as unknown as CometChat . Conversation ;
581581
582582 if (
583583 conv &&
@@ -590,17 +590,17 @@ export const CometChatConversations = (props: ConversationInterface) => {
590590 if (
591591 conv &&
592592 conv ?. getLastMessage &&
593- ( conv . getLastMessage ( ) . id == receipt [ 'messageId' ] ||
594- conv . getLastMessage ( ) . messageId == receipt [ 'messageId' ] )
593+ ( conv . getLastMessage ( ) . id == receipt . getMessageId ( ) ||
594+ conv . getLastMessage ( ) . messageId == receipt . getMessageId ( ) )
595595 ) {
596596 let newConversation = CommonUtils . clone ( conv ) ;
597- if ( receipt [ 'readAt' ] ) {
598- newConversation . getLastMessage ( ) . setReadAt ( receipt [ 'readAt' ] ) ;
597+ if ( receipt . getReadAt ( ) ) {
598+ newConversation . getLastMessage ( ) . setReadAt ( receipt . getReadAt ( ) ) ;
599599 }
600- if ( receipt [ 'deliveredAt' ] ) {
601- newConversation . getLastMessage ( ) . setDeliveredAt ( receipt [ 'deliveredAt' ] ) ;
600+ if ( receipt . getDeliveredAt ( ) ) {
601+ newConversation . getLastMessage ( ) . setDeliveredAt ( receipt . getDeliveredAt ( ) ) ;
602602 }
603- conversationListRef . current . updateList ( newConversation ) ;
603+ conversationListRef . current ? .updateList ( newConversation ) ;
604604 }
605605 } ;
606606
@@ -749,7 +749,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
749749
750750 function getFormattedText ( message : CometChat . BaseMessage , subtitle : string ) {
751751 let messageTextTmp = subtitle ;
752- let allFormatters = [ ...( textFormatters || [ ] ) ] || [ ] ;
752+ let allFormatters = [ ...( textFormatters ?? [ ] ) ] ;
753753
754754 if ( ! disableMentions && message . getMentionedUsers ( ) . length ) {
755755 let mentionsFormatter = ChatConfigurator . getDataSource ( ) . getMentionsFormatter ( ) ;
@@ -1057,14 +1057,8 @@ export const CometChatConversations = (props: ConversationInterface) => {
10571057 {
10581058 ccConversationDeleted :
10591059 ( { conversation } : { conversation : CometChat . Conversation | any } ) => {
1060- CometChat . deleteConversation ( conversation . getConversationId ( ) , conversation . getConversationType ( ) )
1061- . then ( ( res : any ) => {
1062- conversationListRef . current ?. removeItemFromList ( conversation ) ;
1063- removeItemFromSelectionList ( conversation . getConversationId ( ) )
1064- } )
1065- . catch ( ( err : any ) => {
1066- console . log ( "Error" , err ) ;
1067- } ) ;
1060+ conversationListRef . current ?. removeItemFromList ( conversation . getConversationId ( ) ) ;
1061+ removeItemFromSelectionList ( conversation . getConversationId ( ) )
10681062 }
10691063 }
10701064 ) ;
0 commit comments