diff --git a/dist/index.js b/dist/index.js index 32b395d3..02c48b4e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -938,17 +938,10 @@ chatMessage.status = "sent" /* Sent */; this.addMessage(chatMessage); }; - // sorting - get index() { - return this.chatListModel.getIndexOfPrimaryChannel( - this.info.primaryChannel - ); - } // settings setPrimaryChannel = (primaryChannel) => { this.info.primaryChannel = primaryChannel; this.storeInfo(); - this.chatListModel.updateIndices(); this.subscribe(); }; setSecondaryChannels = (secondaryChannels) => { @@ -1133,7 +1126,6 @@ connectionModel; // data chatModels = /* @__PURE__ */ new Set(); - sortedPrimaryChannels = []; // handlers messageHandler = (data) => { for (const chatModel of this.chatModels) { @@ -1149,22 +1141,9 @@ } } }; - // sorting - updateIndices = () => { - this.sortedPrimaryChannels = []; - let allChannels = []; - for (const chatModel of this.chatModels) { - allChannels.push(chatModel.info.primaryChannel); - } - this.sortedPrimaryChannels = allChannels.sort(localeCompare); - }; - getIndexOfPrimaryChannel(primaryChannel) { - return this.sortedPrimaryChannels.indexOf(primaryChannel); - } // storage addChatModel = (chatModel) => { this.chatModels.add(chatModel); - this.updateIndices(); }; createChat = (primaryChannel) => { const id = v4_default(); @@ -1181,7 +1160,6 @@ }; untrackChat = (chat) => { this.chatModels.delete(chat); - this.updateIndices(); }; // load loadChats = () => { @@ -1471,10 +1449,6 @@ selectedPage = new State( "messages" /* Messages */ ); - // sorting - updateIndex = () => { - this.index.value = this.chatModel.index; - }; // view open = () => { this.chatListViewModel.openChat(this); @@ -1517,7 +1491,6 @@ } ); this.loadPageSelection(); - this.updateIndex(); } }; @@ -1543,7 +1516,6 @@ this.newChatPrimaryChannel.value = ""; const chatViewModel = this.createChatViewModel(chatModel); this.chatViewModels.add(chatViewModel); - this.updateIndices(); }; untrackChat = (chatViewModel) => { this.chatListModel.untrackChat(chatViewModel.chatModel); @@ -1564,12 +1536,6 @@ closeChat = () => { this.selectedChat.value = void 0; }; - // sorting - updateIndices = () => { - for (const chatViewModel of this.chatViewModels.value) { - chatViewModel.updateIndex(); - } - }; // load loadChats = () => { this.chatViewModels.clear(); diff --git a/src/Model/Chat/chatListModel.ts b/src/Model/Chat/chatListModel.ts index 5afadef3..bb5c7216 100644 --- a/src/Model/Chat/chatListModel.ts +++ b/src/Model/Chat/chatListModel.ts @@ -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(); - 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 diff --git a/src/Model/Chat/chatModel.ts b/src/Model/Chat/chatModel.ts index d8bb85b0..3d3272ce 100644 --- a/src/Model/Chat/chatModel.ts +++ b/src/Model/Chat/chatModel.ts @@ -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(); }; diff --git a/src/ViewModel/Chat/chatListViewModel.ts b/src/ViewModel/Chat/chatListViewModel.ts index d46a3c94..b4f5e84e 100644 --- a/src/ViewModel/Chat/chatListViewModel.ts +++ b/src/ViewModel/Chat/chatListViewModel.ts @@ -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(); diff --git a/src/ViewModel/Chat/chatViewModel.ts b/src/ViewModel/Chat/chatViewModel.ts index 3a467502..01f8852e 100644 --- a/src/ViewModel/Chat/chatViewModel.ts +++ b/src/ViewModel/Chat/chatViewModel.ts @@ -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(); } }