remove chat sorting
This commit is contained in:
Vendored
-34
@@ -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();
|
||||
|
||||
@@ -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