add guard cannotSendMessage

This commit is contained in:
marlon-erler
2024-07-20 21:04:41 +02:00
parent 9f93856829
commit f3e4be375f
6 changed files with 51 additions and 18 deletions
+16 -4
View File
@@ -3,11 +3,13 @@ import * as React from "bloatless-react";
import ChatListModel from "../Model/chatListModel";
import { ChatModel } from "../Model/chatModel";
import ChatViewModel from "./chatViewModel";
import SettingsViewModel from "./settingsViewModel";
import StorageModel from "../Model/storageModel";
export default class ChatListViewModel {
chatListModel: ChatListModel;
storageModel: StorageModel;
settingsViewModel: SettingsViewModel;
// state
newChatPrimaryChannel: React.State<string> = new React.State("");
@@ -42,8 +44,13 @@ export default class ChatListViewModel {
};
createChatViewModel = (chatModel: ChatModel): ChatViewModel => {
return new ChatViewModel(chatModel, this.storageModel, this);
}
return new ChatViewModel(
chatModel,
this.storageModel,
this.settingsViewModel,
this
);
};
// view
openChat = (chatViewModel: ChatViewModel): void => {
@@ -59,7 +66,7 @@ export default class ChatListViewModel {
for (const chatViewModel of this.chatViewModels.value) {
chatViewModel.updateIndex();
}
}
};
// restore
restoreChats = (): void => {
@@ -71,9 +78,14 @@ export default class ChatListViewModel {
};
// init
constructor(chatListModel: ChatListModel, storageModel: StorageModel) {
constructor(
chatListModel: ChatListModel,
storageModel: StorageModel,
settingsViewModel: SettingsViewModel
) {
this.chatListModel = chatListModel;
this.storageModel = storageModel;
this.settingsViewModel = settingsViewModel;
this.restoreChats();
}