remove chat sorting
This commit is contained in:
@@ -4,7 +4,6 @@ import ChatModel from "./chatModel";
|
||||
import ConnectionModel from "../Global/connectionModel";
|
||||
import { Message } from "udn-frontend";
|
||||
import SettingsModel from "../Global/settingsModel";
|
||||
import { localeCompare } from "../Utility/utility";
|
||||
import { v4 } from "uuid";
|
||||
|
||||
export default class ChatListModel {
|
||||
@@ -14,7 +13,6 @@ export default class ChatListModel {
|
||||
|
||||
// data
|
||||
chatModels = new Set<ChatModel>();
|
||||
sortedPrimaryChannels: string[] = [];
|
||||
|
||||
// handlers
|
||||
messageHandler = (data: Message): void => {
|
||||
@@ -33,26 +31,9 @@ export default class ChatListModel {
|
||||
}
|
||||
};
|
||||
|
||||
// sorting
|
||||
updateIndices = () => {
|
||||
this.sortedPrimaryChannels = [];
|
||||
|
||||
let allChannels: string[] = [];
|
||||
for (const chatModel of this.chatModels) {
|
||||
allChannels.push(chatModel.info.primaryChannel);
|
||||
}
|
||||
|
||||
this.sortedPrimaryChannels = allChannels.sort(localeCompare);
|
||||
};
|
||||
|
||||
getIndexOfPrimaryChannel(primaryChannel: string): number {
|
||||
return this.sortedPrimaryChannels.indexOf(primaryChannel);
|
||||
}
|
||||
|
||||
// storage
|
||||
addChatModel = (chatModel: ChatModel) => {
|
||||
this.chatModels.add(chatModel);
|
||||
this.updateIndices();
|
||||
};
|
||||
|
||||
createChat = (primaryChannel: string): ChatModel => {
|
||||
@@ -73,7 +54,6 @@ export default class ChatListModel {
|
||||
|
||||
untrackChat = (chat: ChatModel): void => {
|
||||
this.chatModels.delete(chat);
|
||||
this.updateIndices();
|
||||
};
|
||||
|
||||
// load
|
||||
|
||||
@@ -74,18 +74,10 @@ export default class ChatModel {
|
||||
this.addMessage(chatMessage);
|
||||
};
|
||||
|
||||
// sorting
|
||||
get index(): number {
|
||||
return this.chatListModel.getIndexOfPrimaryChannel(
|
||||
this.info.primaryChannel
|
||||
);
|
||||
}
|
||||
|
||||
// settings
|
||||
setPrimaryChannel = (primaryChannel: string): void => {
|
||||
this.info.primaryChannel = primaryChannel;
|
||||
this.storeInfo();
|
||||
this.chatListModel.updateIndices();
|
||||
this.subscribe();
|
||||
};
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@ export default class ChatListViewModel {
|
||||
|
||||
const chatViewModel: ChatViewModel = this.createChatViewModel(chatModel);
|
||||
this.chatViewModels.add(chatViewModel);
|
||||
|
||||
this.updateIndices();
|
||||
};
|
||||
|
||||
untrackChat = (chatViewModel: ChatViewModel): void => {
|
||||
@@ -61,13 +59,6 @@ export default class ChatListViewModel {
|
||||
this.selectedChat.value = undefined;
|
||||
};
|
||||
|
||||
// sorting
|
||||
updateIndices = (): void => {
|
||||
for (const chatViewModel of this.chatViewModels.value) {
|
||||
chatViewModel.updateIndex();
|
||||
}
|
||||
};
|
||||
|
||||
// load
|
||||
loadChats = (): void => {
|
||||
this.chatViewModels.clear();
|
||||
|
||||
@@ -27,11 +27,6 @@ export default class ChatViewModel {
|
||||
ChatPageType.Messages
|
||||
);
|
||||
|
||||
// sorting
|
||||
updateIndex = (): void => {
|
||||
this.index.value = this.chatModel.index;
|
||||
};
|
||||
|
||||
// view
|
||||
open = (): void => {
|
||||
this.chatListViewModel.openChat(this);
|
||||
@@ -90,7 +85,6 @@ export default class ChatViewModel {
|
||||
|
||||
// load
|
||||
this.loadPageSelection();
|
||||
this.updateIndex();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user