implement contacts model and vm with chat model

This commit is contained in:
marlon-erler
2026-09-27 02:41:49 +02:00
parent 66a88ac1b1
commit c5d61a5790
5 changed files with 31 additions and 28 deletions
+8 -14
View File
@@ -1,5 +1,3 @@
// cleanup: Phase A
import { v4 } from "uuid";
import ChatListModel from "./chatListModel";
import {
@@ -23,13 +21,10 @@ import SettingsModel from "../Global/settingsModel";
import ConnectionModel from "../Global/connectionModel";
import FileModel, { FileContent } from "../Files/fileModel";
import { Colors } from "../../colors";
import ContactListModel from "../Global/contactListModel";
export default class ChatModel {
// models
readonly connectionModel: ConnectionModel;
readonly storageModel: StorageModel;
readonly settingsModel: SettingsModel;
readonly chatListModel: ChatListModel;
readonly fileModel: FileModel;
// data
@@ -167,6 +162,8 @@ export default class ChatModel {
readonly addMessage = async (chatMessage: ChatMessage): Promise<void> => {
await this.decryptMessage(chatMessage);
this.contactListModel.storeContact(chatMessage.senderId, chatMessage.senderName);
// message
if (chatMessage.body != "") {
const messagePath: string[] = this.getMessagePath(chatMessage.id);
@@ -349,17 +346,14 @@ export default class ChatModel {
// init
constructor(
storageModel: StorageModel,
connectionModel: ConnectionModel,
settingsModel: SettingsModel,
chatListModel: ChatListModel,
public storageModel: StorageModel,
public connectionModel: ConnectionModel,
public settingsModel: SettingsModel,
public chatListModel: ChatListModel,
public contactListModel: ContactListModel,
chatId: string,
) {
this.id = chatId;
this.connectionModel = connectionModel;
this.settingsModel = settingsModel;
this.storageModel = storageModel;
this.chatListModel = chatListModel;
this.loadInfo();
this.subscribe();