diff --git a/dist/index.js b/dist/index.js index 0e8fd85f..37e78682 100644 --- a/dist/index.js +++ b/dist/index.js @@ -777,7 +777,6 @@ this.chatModel = chatModel; this.fileModel = fileModel; this.storageModel = storageModel2; - fileModel.fileContentHandlerManager.addHandler(this.handleFileContent); } // utility static createBoardInfoFileContent = (fileId, name, color) => { @@ -822,12 +821,60 @@ boardId: "" }; + // src/Model/Files/calendarModel.ts + var CalendarModel = class _CalendarModel { + storageModel; + fileModel; + // paths + getBasePath = () => { + return this.fileModel.getModelContainerPath("calendar" /* ModelCalendar */); + }; + getViewPath = () => { + return [...this.getBasePath(), "view" /* ModelView */]; + }; + getMonthContainerPath = () => { + return [...this.getBasePath(), "months" /* Months */]; + }; + getMonthPath = (monthString) => { + return [...this.getMonthContainerPath(), monthString]; + }; + // handlers + handleFileContent = (fileContent) => { + if (checkMatchesObjectStructure(fileContent, TaskFileContentReference) == false) + return; + }; + // main + storeTaskReference = (taskFileContent) => { + if (taskFileContent.date == void 0) return; + const monthString = _CalendarModel.isoToMonthString( + taskFileContent.date + ); + const monthPath = this.getMonthPath(monthString); + const referencePath = [...monthPath, taskFileContent.fileId]; + this.storageModel.write(referencePath, ""); + }; + listTaskIds = (monthString) => { + const monthPath = this.getMonthPath(monthString); + return this.storageModel.list(monthPath); + }; + // init + constructor(storageModel2, fileModel) { + this.storageModel = storageModel2; + this.fileModel = fileModel; + } + // utility + static isoToMonthString = (dateISOString) => { + const [year, month, _] = dateISOString.split("-"); + return `${year}-${month}`; + }; + }; + // src/Model/Files/fileModel.ts var FileModel = class _FileModel { chatModel; storageModel; boardsAndTasksModel; - fileContentHandlerManager = new HandlerManager(); + calendarModel; // paths getBasePath = () => { return StorageModel.getPath( @@ -861,7 +908,7 @@ const didStore = this.storeFileContent(fileContent); if (didStore == false) return; this.boardsAndTasksModel.handleFileContent(fileContent); - this.fileContentHandlerManager.trigger(fileContent); + this.calendarModel.handleFileContent(fileContent); }; // methods addFileContentAndSend = (fileContent) => { @@ -914,6 +961,7 @@ this.chatModel = chatModel; this.storageModel = storageModel2; this.boardsAndTasksModel = new BoardsAndTasksModel(this.storageModel, chatModel, this); + this.calendarModel = new CalendarModel(this.storageModel, this); } // utility static generateFileContentId = (creationDate) => { diff --git a/src/Model/Files/boardsAndTasksModel.ts b/src/Model/Files/boardsAndTasksModel.ts index 85feae48..25bb8387 100644 --- a/src/Model/Files/boardsAndTasksModel.ts +++ b/src/Model/Files/boardsAndTasksModel.ts @@ -220,9 +220,6 @@ export default class BoardsAndTasksModel { this.chatModel = chatModel; this.fileModel = fileModel; this.storageModel = storageModel; - - // handlers - fileModel.fileContentHandlerManager.addHandler(this.handleFileContent); } // utility diff --git a/src/Model/Files/calendarModel.ts b/src/Model/Files/calendarModel.ts index a4428a7a..937cfaf5 100644 --- a/src/Model/Files/calendarModel.ts +++ b/src/Model/Files/calendarModel.ts @@ -14,8 +14,6 @@ export default class CalendarModel { storageModel: StorageModel; fileModel: FileModel; - boardsAndTasksModel: BoardsAndTasksModel; - // paths getBasePath = (): string[] => { return this.fileModel.getModelContainerPath(FileModelSubPath.ModelCalendar); @@ -63,12 +61,9 @@ export default class CalendarModel { // init constructor( storageModel: StorageModel, - fileModel: FileModel, - boardsAndTasksModel: BoardsAndTasksModel - ) { + fileModel: FileModel, ) { this.storageModel = storageModel; this.fileModel = fileModel; - this.boardsAndTasksModel = boardsAndTasksModel; } // utility diff --git a/src/Model/Files/fileModel.ts b/src/Model/Files/fileModel.ts index 6075543b..eb3bbac7 100644 --- a/src/Model/Files/fileModel.ts +++ b/src/Model/Files/fileModel.ts @@ -11,6 +11,7 @@ import { import StorageModel, { StorageModelSubPath, filePaths } from "../Global/storageModel"; import BoardsAndTasksModel from "./boardsAndTasksModel"; +import CalendarModel from "./calendarModel"; import ChatModel from "../Chat/chatModel"; import { v4 } from "uuid"; @@ -19,8 +20,7 @@ export default class FileModel { storageModel: StorageModel; boardsAndTasksModel: BoardsAndTasksModel; - - fileContentHandlerManager: HandlerManager> = new HandlerManager(); + calendarModel: CalendarModel; // paths getBasePath = (): string[] => { @@ -65,7 +65,7 @@ export default class FileModel { if (didStore == false) return; this.boardsAndTasksModel.handleFileContent(fileContent); - this.fileContentHandlerManager.trigger(fileContent); + this.calendarModel.handleFileContent(fileContent); }; // methods @@ -142,6 +142,7 @@ export default class FileModel { this.storageModel = storageModel; this.boardsAndTasksModel = new BoardsAndTasksModel(this.storageModel, chatModel, this); + this.calendarModel = new CalendarModel(this.storageModel, this); } // utility