sort chats alphabetically

This commit is contained in:
marlon-erler
2024-07-20 16:49:01 +02:00
parent 588ae560a5
commit 54b7be421c
5 changed files with 75 additions and 6 deletions
+10 -1
View File
@@ -14,7 +14,7 @@ export default class ChatListViewModel {
chatViewModels: React.ListState<ChatViewModel> = new React.ListState();
selectedChat: React.State<ChatViewModel | undefined> = new React.State<
ChatViewModel | undefined
ChatViewModel | undefined
>(undefined);
// guards
@@ -23,6 +23,15 @@ export default class ChatListViewModel {
() => this.newChatPrimaryChannel.value == ""
);
// sorting
get sortedPrimaryChannels(): string[] {
return this.chatListModel.sortedPrimaryChannels;
}
getIndexOfChat(chat: ChatViewModel): number {
return this.sortedPrimaryChannels.indexOf(chat.primaryChannel.value);
}
// methods
createChat = (): void => {
const chatModel: ChatModel = this.chatListModel.createChat(