@@ -43,10 +43,10 @@ export class ChatService {
4343
4444 // Filter chats that have exactly the same participants (order doesn't matter)
4545 const sortedParticipantIds = participantIds . sort ( ) ;
46-
46+
4747 for ( const chat of chats ) {
4848 const chatParticipantIds = chat . participants . map ( p => p . id ) . sort ( ) ;
49-
49+
5050 if ( chatParticipantIds . length === sortedParticipantIds . length &&
5151 chatParticipantIds . every ( ( id , index ) => id === sortedParticipantIds [ index ] ) ) {
5252 return chat ;
@@ -162,11 +162,7 @@ export class ChatService {
162162 } ) ;
163163
164164 const savedMessage = await this . messageRepository . save ( message ) ;
165-
166- // Update the chat's updatedAt timestamp to reflect the latest message
167- chat . updatedAt = new Date ( ) ;
168- await this . chatRepository . save ( chat ) ;
169-
165+
170166 console . log ( "Sent event" , `chat:${ chatId } ` ) ;
171167 this . eventEmitter . emit ( `chat:${ chatId } ` , [ savedMessage ] ) ;
172168
@@ -317,13 +313,13 @@ export class ChatService {
317313 const sortedChats = chatsWithRelations . sort ( ( a , b ) => {
318314 const aLatestMessage = a . messages [ a . messages . length - 1 ] ;
319315 const bLatestMessage = b . messages [ b . messages . length - 1 ] ;
320-
316+
321317 if ( ! aLatestMessage && ! bLatestMessage ) {
322318 return b . createdAt . getTime ( ) - a . createdAt . getTime ( ) ;
323319 }
324320 if ( ! aLatestMessage ) return 1 ;
325321 if ( ! bLatestMessage ) return - 1 ;
326-
322+
327323 return bLatestMessage . createdAt . getTime ( ) - aLatestMessage . createdAt . getTime ( ) ;
328324 } ) ;
329325
0 commit comments