Skip to content

Commit

Permalink
Update with updatedDate in consideration
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutugiii committed Dec 20, 2023
1 parent 1b6c90b commit 469ed7f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app/chat/chat-sidebar/chat-sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down

0 comments on commit 469ed7f

Please sign in to comment.