cleanup, add fileContentHandler for ViewModel

This commit is contained in:
marlon-erler
2024-07-23 00:25:28 +02:00
parent 224c00c8d8
commit 39b50e9254
6 changed files with 109 additions and 49 deletions
+5 -4
View File
@@ -159,10 +159,6 @@ export default class ChatModel {
chatMessage.stringifiedFile = decryptedFile;
};
setMessageHandler = (handler: (chatMessage: ChatMessage) => void): void => {
this.chatMessageHandler = handler;
};
subscribe = (): void => {
this.connectionModel.addChannel(this.info.primaryChannel);
};
@@ -185,6 +181,11 @@ export default class ChatModel {
this.storageModel.removeRecursively(dirPath);
};
// other
setMessageHandler = (handler: (chatMessage: ChatMessage) => void): void => {
this.chatMessageHandler = handler;
};
// load
loadInfo = (): void => {
const info: ChatInfo | null = this.storageModel.readStringifiable(
+9 -1
View File
@@ -9,7 +9,6 @@ import {
} from "../Utility/utility";
import ChatModel from "../Chat/chatModel";
import { Color } from "../../colors";
import TaskModel from "./taskModel";
import { v4 } from "uuid";
@@ -19,6 +18,9 @@ export default class FileModel {
taskModel: TaskModel;
fileContentHandler: (fileContent: FileContent<string>) => void = () => {};
// paths
getBasePath = (): string[] => {
return StorageModel.getPath(
@@ -62,6 +64,7 @@ export default class FileModel {
if (didStore == false) return;
this.taskModel.handleFileContent(fileContent);
this.fileContentHandler(fileContent);
};
// methods
@@ -132,6 +135,11 @@ export default class FileModel {
return fileContent;
};
// other
setFileContentHandler = (handler: (fileContent: FileContent<string>) => void): void => {
this.fileContentHandler = handler;
};
// init
constructor(chatModel: ChatModel, storageModel: StorageModel) {
this.chatModel = chatModel;