Skip to content

Commit

Permalink
Sort based on the createdDate db field
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutugiii committed Dec 20, 2023
1 parent e84d0b2 commit 1b6c90b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/chat/chat-sidebar/chat-sidebar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</div>
<ng-container *ngIf="filteredConversations?.length; else noChats">
<ul>
<li *ngFor="let conversation of filteredConversations.reverse(); let i = index" (click)="selectConversation(conversation)">
<li *ngFor="let conversation of filteredConversations; let i = index" (click)="selectConversation(conversation)">
<ng-container *ngIf="isEditing; else notEditing">
<ng-container *ngIf="selectedConversation?._id === conversation?._id; else conversationTitle">
<form [formGroup]="titleForm[conversation?._id]" (ngSubmit)="submitTitle(conversation)">
Expand Down
4 changes: 2 additions & 2 deletions src/app/chat/chat-sidebar/chat-sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export class ChatSidebarComponent implements OnInit, OnDestroy {

getChatHistory() {
this.chatService.findConversations([], [ this.userService.get().name ]).subscribe(
(conversations) => {
this.conversations = conversations;
(conversations: any) => {
this.conversations = conversations.sort((a, b) => b.createdDate - a.createdDate);
this.filteredConversations = [ ...conversations ];
this.initializeFormGroups();
},
Expand Down

0 comments on commit 1b6c90b

Please sign in to comment.