remove chat sorting

This commit is contained in:
marlon-erler
2024-07-23 01:07:23 +02:00
parent 267bdcfc73
commit 1e4cc8a39a
5 changed files with 0 additions and 77 deletions
-34
View File
@@ -938,17 +938,10 @@
chatMessage.status = "sent" /* Sent */; chatMessage.status = "sent" /* Sent */;
this.addMessage(chatMessage); this.addMessage(chatMessage);
}; };
// sorting
get index() {
return this.chatListModel.getIndexOfPrimaryChannel(
this.info.primaryChannel
);
}
// settings // settings
setPrimaryChannel = (primaryChannel) => { setPrimaryChannel = (primaryChannel) => {
this.info.primaryChannel = primaryChannel; this.info.primaryChannel = primaryChannel;
this.storeInfo(); this.storeInfo();
this.chatListModel.updateIndices();
this.subscribe(); this.subscribe();
}; };
setSecondaryChannels = (secondaryChannels) => { setSecondaryChannels = (secondaryChannels) => {
@@ -1133,7 +1126,6 @@
connectionModel; connectionModel;
// data // data
chatModels = /* @__PURE__ */ new Set(); chatModels = /* @__PURE__ */ new Set();
sortedPrimaryChannels = [];
// handlers // handlers
messageHandler = (data) => { messageHandler = (data) => {
for (const chatModel of this.chatModels) { 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 // storage
addChatModel = (chatModel) => { addChatModel = (chatModel) => {
this.chatModels.add(chatModel); this.chatModels.add(chatModel);
this.updateIndices();
}; };
createChat = (primaryChannel) => { createChat = (primaryChannel) => {
const id = v4_default(); const id = v4_default();
@@ -1181,7 +1160,6 @@
}; };
untrackChat = (chat) => { untrackChat = (chat) => {
this.chatModels.delete(chat); this.chatModels.delete(chat);
this.updateIndices();
}; };
// load // load
loadChats = () => { loadChats = () => {
@@ -1471,10 +1449,6 @@
selectedPage = new State( selectedPage = new State(
"messages" /* Messages */ "messages" /* Messages */
); );
// sorting
updateIndex = () => {
this.index.value = this.chatModel.index;
};
// view // view
open = () => { open = () => {
this.chatListViewModel.openChat(this); this.chatListViewModel.openChat(this);
@@ -1517,7 +1491,6 @@
} }
); );
this.loadPageSelection(); this.loadPageSelection();
this.updateIndex();
} }
}; };
@@ -1543,7 +1516,6 @@
this.newChatPrimaryChannel.value = ""; this.newChatPrimaryChannel.value = "";
const chatViewModel = this.createChatViewModel(chatModel); const chatViewModel = this.createChatViewModel(chatModel);
this.chatViewModels.add(chatViewModel); this.chatViewModels.add(chatViewModel);
this.updateIndices();
}; };
untrackChat = (chatViewModel) => { untrackChat = (chatViewModel) => {
this.chatListModel.untrackChat(chatViewModel.chatModel); this.chatListModel.untrackChat(chatViewModel.chatModel);
@@ -1564,12 +1536,6 @@
closeChat = () => { closeChat = () => {
this.selectedChat.value = void 0; this.selectedChat.value = void 0;
}; };
// sorting
updateIndices = () => {
for (const chatViewModel of this.chatViewModels.value) {
chatViewModel.updateIndex();
}
};
// load // load
loadChats = () => { loadChats = () => {
this.chatViewModels.clear(); this.chatViewModels.clear();
-20
View File
@@ -4,7 +4,6 @@ import ChatModel from "./chatModel";
import ConnectionModel from "../Global/connectionModel"; import ConnectionModel from "../Global/connectionModel";
import { Message } from "udn-frontend"; import { Message } from "udn-frontend";
import SettingsModel from "../Global/settingsModel"; import SettingsModel from "../Global/settingsModel";
import { localeCompare } from "../Utility/utility";
import { v4 } from "uuid"; import { v4 } from "uuid";
export default class ChatListModel { export default class ChatListModel {
@@ -14,7 +13,6 @@ export default class ChatListModel {
// data // data
chatModels = new Set<ChatModel>(); chatModels = new Set<ChatModel>();
sortedPrimaryChannels: string[] = [];
// handlers // handlers
messageHandler = (data: Message): void => { 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 // storage
addChatModel = (chatModel: ChatModel) => { addChatModel = (chatModel: ChatModel) => {
this.chatModels.add(chatModel); this.chatModels.add(chatModel);
this.updateIndices();
}; };
createChat = (primaryChannel: string): ChatModel => { createChat = (primaryChannel: string): ChatModel => {
@@ -73,7 +54,6 @@ export default class ChatListModel {
untrackChat = (chat: ChatModel): void => { untrackChat = (chat: ChatModel): void => {
this.chatModels.delete(chat); this.chatModels.delete(chat);
this.updateIndices();
}; };
// load // load
-8
View File
@@ -74,18 +74,10 @@ export default class ChatModel {
this.addMessage(chatMessage); this.addMessage(chatMessage);
}; };
// sorting
get index(): number {
return this.chatListModel.getIndexOfPrimaryChannel(
this.info.primaryChannel
);
}
// settings // settings
setPrimaryChannel = (primaryChannel: string): void => { setPrimaryChannel = (primaryChannel: string): void => {
this.info.primaryChannel = primaryChannel; this.info.primaryChannel = primaryChannel;
this.storeInfo(); this.storeInfo();
this.chatListModel.updateIndices();
this.subscribe(); this.subscribe();
}; };
-9
View File
@@ -34,8 +34,6 @@ export default class ChatListViewModel {
const chatViewModel: ChatViewModel = this.createChatViewModel(chatModel); const chatViewModel: ChatViewModel = this.createChatViewModel(chatModel);
this.chatViewModels.add(chatViewModel); this.chatViewModels.add(chatViewModel);
this.updateIndices();
}; };
untrackChat = (chatViewModel: ChatViewModel): void => { untrackChat = (chatViewModel: ChatViewModel): void => {
@@ -61,13 +59,6 @@ export default class ChatListViewModel {
this.selectedChat.value = undefined; this.selectedChat.value = undefined;
}; };
// sorting
updateIndices = (): void => {
for (const chatViewModel of this.chatViewModels.value) {
chatViewModel.updateIndex();
}
};
// load // load
loadChats = (): void => { loadChats = (): void => {
this.chatViewModels.clear(); this.chatViewModels.clear();
-6
View File
@@ -27,11 +27,6 @@ export default class ChatViewModel {
ChatPageType.Messages ChatPageType.Messages
); );
// sorting
updateIndex = (): void => {
this.index.value = this.chatModel.index;
};
// view // view
open = (): void => { open = (): void => {
this.chatListViewModel.openChat(this); this.chatListViewModel.openChat(this);
@@ -90,7 +85,6 @@ export default class ChatViewModel {
// load // load
this.loadPageSelection(); this.loadPageSelection();
this.updateIndex();
} }
} }