use chat Id as channel, remove primary channels and namespaces
This commit is contained in:
@@ -13,7 +13,7 @@ export default class ChatListViewModel {
|
||||
// data
|
||||
readonly chatIndexManager = new IndexManager<ChatViewModel>(
|
||||
(chatViewModel: ChatViewModel) =>
|
||||
chatViewModel.settingsPageViewModel.primaryChannel.value,
|
||||
chatViewModel.settingsPageViewModel.name.value,
|
||||
);
|
||||
|
||||
// state
|
||||
@@ -104,10 +104,10 @@ export default class ChatListViewModel {
|
||||
}
|
||||
|
||||
// utility
|
||||
stripNamespace = (fullChannel: string): string => {
|
||||
getDisplayName = (fullChannel: string): string => {
|
||||
for (const vm of this.chatViewModels.value) {
|
||||
const fullReference = vm.chatModel.unwrappedPrimaryChannel;
|
||||
if (fullReference == fullChannel) return vm.chatModel.info.primaryChannel;
|
||||
const fullReference = vm.chatModel.id;
|
||||
if (fullReference == fullChannel) return vm.chatModel.info.name;
|
||||
}
|
||||
|
||||
return fullChannel;
|
||||
|
||||
@@ -184,7 +184,7 @@ export default class ChatMessageViewModel {
|
||||
this.messagePageViewModel.chatMessageViewModels.value.get(
|
||||
this.chatMessage.inlineReplyId,
|
||||
);
|
||||
this.inlineReply.replies.set(this.chatMessage.id, this);
|
||||
this.inlineReply?.replies.set(this.chatMessage.id, this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ export default class FileTransferViewModel extends Context {
|
||||
this.coreViewModel.chatListModel.chatModels;
|
||||
for (const chatModel of chatModels) {
|
||||
this.chatFileOptions.add({
|
||||
label: chatModel.unwrappedPrimaryChannel,
|
||||
label: chatModel.info.name,
|
||||
path: chatModel.getBasePath(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export default class NotificationViewModel {
|
||||
this.createNotification(message);
|
||||
const currentChat =
|
||||
this.chatListViewModel.selectedChat.value.chatModel
|
||||
.unwrappedPrimaryChannel;
|
||||
.id;
|
||||
const currentPage =
|
||||
this.chatListViewModel.selectedChat.value.selectedPage.value;
|
||||
if (
|
||||
@@ -41,7 +41,7 @@ export default class NotificationViewModel {
|
||||
...this.chatListViewModel.chatViewModels.value.values(),
|
||||
].find(
|
||||
(chat) =>
|
||||
chat.chatModel.unwrappedPrimaryChannel == notification.fullChannel,
|
||||
chat.chatModel.id == notification.fullChannel,
|
||||
);
|
||||
if (!chat) return;
|
||||
chat.open();
|
||||
@@ -87,7 +87,7 @@ export default class NotificationViewModel {
|
||||
// util
|
||||
createNotification(message: ChatMessage): Notification {
|
||||
const fullChannel = ChatModel.splitChannel(message.channel)[0];
|
||||
const chat = this.chatListViewModel.stripNamespace(fullChannel);
|
||||
const chat = this.chatListViewModel.getDisplayName(fullChannel);
|
||||
return {
|
||||
messageId: message.id,
|
||||
chat,
|
||||
|
||||
@@ -40,7 +40,7 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel {
|
||||
MonthGrid<React.MapState<TaskViewModel>> | undefined
|
||||
> = new React.State<any>(undefined);
|
||||
|
||||
nextTask: React.State<TaskViewModel|undefined> = new React.State(undefined);
|
||||
nextTask = new React.State<TaskViewModel|undefined>(undefined);
|
||||
|
||||
// methods
|
||||
createEvent = (): void => {
|
||||
|
||||
@@ -16,7 +16,7 @@ export default class MessagePageViewModel extends Context {
|
||||
new React.MapState();
|
||||
filteredMessageViewModels: React.ListState<ChatMessageViewModel> =
|
||||
new React.ListState();
|
||||
replyViewSelectedMessage: React.State<ChatMessageViewModel|undefined> = new React.State(undefined);
|
||||
replyViewSelectedMessage = new React.State<ChatMessageViewModel|undefined>(undefined);
|
||||
isReplyViewActive: React.State<boolean> = React.createProxyState([this.replyViewSelectedMessage], ()=>this.replyViewSelectedMessage.value != undefined);
|
||||
isReplyViewInactive = React.createProxyState([this.isReplyViewActive], ()=>!this.isReplyViewActive.value);
|
||||
searchViewModel: SearchViewModel<ChatMessageViewModel>;
|
||||
|
||||
@@ -5,11 +5,8 @@ import { Colors } from "../../colors";
|
||||
|
||||
export default class SettingsPageViewModel extends Context {
|
||||
// state
|
||||
primaryChannel: React.State<string> = new React.State("");
|
||||
primaryChannelInput: React.State<string> = new React.State("");
|
||||
|
||||
namespace: React.State<string> = new React.State("");
|
||||
namespaceInput: React.State<string> = new React.State("");
|
||||
name: React.State<string> = new React.State("");
|
||||
nameInput: React.State<string> = new React.State("");
|
||||
|
||||
secondaryChannels: React.ListState<string> = new React.ListState();
|
||||
newSecondaryChannelInput: React.State<string> = new React.State("");
|
||||
@@ -25,14 +22,10 @@ export default class SettingsPageViewModel extends Context {
|
||||
|
||||
// guards
|
||||
cannotSetPrimaryChannel: React.State<boolean> = React.createProxyState(
|
||||
[this.primaryChannel, this.primaryChannelInput],
|
||||
[this.name, this.nameInput],
|
||||
() =>
|
||||
this.primaryChannelInput.value == "" ||
|
||||
this.primaryChannelInput.value == this.primaryChannel.value,
|
||||
);
|
||||
cannotSetNamespace: React.State<boolean> = React.createProxyState(
|
||||
[this.namespace, this.namespaceInput],
|
||||
() => this.namespaceInput.value == this.namespace.value,
|
||||
this.nameInput.value == "" ||
|
||||
this.nameInput.value == this.name.value,
|
||||
);
|
||||
cannotAddSecondaryChannel: React.State<boolean> = React.createProxyState(
|
||||
[this.newSecondaryChannelInput],
|
||||
@@ -41,21 +34,16 @@ export default class SettingsPageViewModel extends Context {
|
||||
cannotSetEncryptionKey: React.State<boolean>;
|
||||
|
||||
// methods
|
||||
setPrimaryChannel = (): void => {
|
||||
this.chatViewModel.chatModel.setPrimaryChannel(
|
||||
this.primaryChannelInput.value,
|
||||
setName = (): void => {
|
||||
this.chatViewModel.chatModel.setName(
|
||||
this.nameInput.value,
|
||||
);
|
||||
this.primaryChannel.value =
|
||||
this.chatViewModel.chatModel.info.primaryChannel;
|
||||
this.name.value =
|
||||
this.chatViewModel.chatModel.info.name;
|
||||
|
||||
this.chatViewModel.chatListViewModel.updateIndices();
|
||||
};
|
||||
|
||||
setNamespace = (): void => {
|
||||
this.chatViewModel.chatModel.setNamespace(this.namespaceInput.value);
|
||||
this.namespace.value = this.chatViewModel.chatModel.info.namespace;
|
||||
};
|
||||
|
||||
addSecondaryChannel = (): void => {
|
||||
this.secondaryChannels.add(this.newSecondaryChannelInput.value);
|
||||
this.newSecondaryChannelInput.value = "";
|
||||
@@ -95,16 +83,14 @@ export default class SettingsPageViewModel extends Context {
|
||||
|
||||
// load
|
||||
preloadData = (): void => {
|
||||
this.primaryChannel.value =
|
||||
this.chatViewModel.chatModel.info.primaryChannel;
|
||||
this.namespace.value = this.chatViewModel.chatModel.info.namespace;
|
||||
this.name.value =
|
||||
this.chatViewModel.chatModel.info.name;
|
||||
|
||||
this.color.value = this.chatViewModel.chatModel.color;
|
||||
};
|
||||
|
||||
loadData = (): void => {
|
||||
this.primaryChannelInput.value = this.primaryChannel.value;
|
||||
this.namespaceInput.value = this.namespace.value;
|
||||
this.nameInput.value = this.name.value;
|
||||
|
||||
this.loadSecondaryChannels();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user