implement model methods for backup

This commit is contained in:
marlon-erler
2026-08-29 02:10:26 +02:00
parent 2c8b078b80
commit 2245fb5885
20 changed files with 11999 additions and 8945 deletions
+16 -5
View File
@@ -57,7 +57,10 @@ export default class BoardsAndTasksModel {
];
};
readonly getTaskReferencePath = (boardId: string, fileId: string): string[] => {
readonly getTaskReferencePath = (
boardId: string,
fileId: string,
): string[] => {
return [...this.getTaskContainerPath(boardId), fileId];
};
@@ -99,17 +102,23 @@ export default class BoardsAndTasksModel {
return boardInfoFileContent;
};
readonly updateBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
readonly updateBoard = (
boardInfoFileContent: BoardInfoFileContent,
): void => {
this.storeBoard(boardInfoFileContent);
this.boardHandlerManager.trigger(boardInfoFileContent);
};
readonly updateBoardAndSend = (boardInfoFileContent: BoardInfoFileContent): void => {
readonly updateBoardAndSend = (
boardInfoFileContent: BoardInfoFileContent,
): void => {
this.updateBoard(boardInfoFileContent);
this.chatModel.sendMessage("", undefined, boardInfoFileContent);
};
readonly storeBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
readonly storeBoard = (
boardInfoFileContent: BoardInfoFileContent,
): void => {
// store info
this.fileModel.storeFileContent(boardInfoFileContent);
@@ -194,7 +203,9 @@ export default class BoardsAndTasksModel {
return versionIds;
};
readonly getLatestTaskFileContent = (taskId: string): TaskFileContent | null => {
readonly getLatestTaskFileContent = (
taskId: string,
): TaskFileContent | null => {
const taskFileContentOrNull: TaskFileContent | null =
this.fileModel.getLatestFileContent(
taskId,
+6 -3
View File
@@ -12,11 +12,11 @@ export default class CalendarModel {
readonly settingsModel: SettingsModel;
// paths
get basePath (): string[] {
get basePath(): string[] {
return this.fileModel.getModelContainerPath(
FileModelSubPath.ModelCalendar,
);
};
}
readonly getViewPath = (): string[] => {
return [...this.basePath, FileModelSubPath.ModelView];
@@ -44,7 +44,10 @@ export default class CalendarModel {
this.storageModel.write(referencePath, "");
};
readonly deleteTaskReference = (monthString: string, taskId: string): void => {
readonly deleteTaskReference = (
monthString: string,
taskId: string,
): void => {
const monthPath: string[] = this.getMonthPath(monthString);
const referencePath: string[] = [...monthPath, taskId];
+14 -5
View File
@@ -29,13 +29,15 @@ export default class FileModel {
StorageModelSubPaths.Chat,
filePaths.chat.files(this.chatModel.id),
);
};
}
readonly getFileContainerPath = (): string[] => {
return [...this.basePath, FileModelSubPath.Data];
};
readonly getModelContainerPath = (modelName: FileModelSubPath): string[] => {
readonly getModelContainerPath = (
modelName: FileModelSubPath,
): string[] => {
return [...this.basePath, FileModelSubPath.Model, modelName];
};
@@ -43,13 +45,18 @@ export default class FileModel {
return [...this.getFileContainerPath(), fileId];
};
readonly getFileContentPath = (fileId: string, fileContentId: string): string[] => {
readonly getFileContentPath = (
fileId: string,
fileContentId: string,
): string[] => {
const filePath: string[] = this.getFilePath(fileId);
return [...filePath, fileContentId];
};
// handlers
readonly handleStringifiedFileContent = (stringifiedFileContent: string): void => {
readonly handleStringifiedFileContent = (
stringifiedFileContent: string,
): void => {
const fileContent: FileContent<string> | null = parseValidObject(
stringifiedFileContent,
FileContentReference,
@@ -68,7 +75,9 @@ export default class FileModel {
};
// methods
readonly addFileContentAndSend = (fileContent: FileContent<string>): void => {
readonly addFileContentAndSend = (
fileContent: FileContent<string>,
): void => {
this.handleFileContent(fileContent);
this.chatModel.sendMessage("", undefined, fileContent);
};