diff --git a/src/app/chat/chat-sidebar/chat-sidebar.component.ts b/src/app/chat/chat-sidebar/chat-sidebar.component.ts index eb9b76ccdb..2f12d60885 100644 --- a/src/app/chat/chat-sidebar/chat-sidebar.component.ts +++ b/src/app/chat/chat-sidebar/chat-sidebar.component.ts @@ -102,7 +102,12 @@ export class ChatSidebarComponent implements OnInit, OnDestroy { getChatHistory() { this.chatService.findConversations([], [ this.userService.get().name ]).subscribe( (conversations: any) => { - this.conversations = conversations.sort((a, b) => b.createdDate - a.createdDate); + this.conversations = conversations.sort((a, b) => { + const dateA = a.updatedDate || a.createdDate; + const dateB = b.updatedDate || b.createdDate; + + return dateB - dateA; + }); this.filteredConversations = [ ...conversations ]; this.initializeFormGroups(); },