diff --git a/src/Model/Chat/.chatModel.ts.swp b/src/Model/Chat/.chatModel.ts.swp new file mode 100644 index 00000000..da4d6d14 Binary files /dev/null and b/src/Model/Chat/.chatModel.ts.swp differ diff --git a/src/Model/Files/.fileModel.ts.swp b/src/Model/Files/.fileModel.ts.swp new file mode 100644 index 00000000..a475fd96 Binary files /dev/null and b/src/Model/Files/.fileModel.ts.swp differ diff --git a/src/Model/Files/fileModel.ts b/src/Model/Files/fileModel.ts index f73997b2..4c52f54d 100644 --- a/src/Model/Files/fileModel.ts +++ b/src/Model/Files/fileModel.ts @@ -70,143 +70,150 @@ export default class FileModel { const didStore: boolean = this.storeFileContent(fileContent); if (didStore == false) return; - this.boardsAndTasksModel.handleFileContent(fileContent); - this.chatModel.handleReaction(fileContent); + switch (fileContent.type) { + case "board-info": + case "task": + this.boardsAndTasksModel.handleFileContent(fileContent); + break; + case "reaction": + this.chatModel.handleReaction(fileContent); + break; + } }; // methods readonly addFileContentAndSend = ( - fileContent: FileContent, + fileContent: FileContent, ): void => { - this.handleFileContent(fileContent); - this.chatModel.sendMessage("", undefined, fileContent); + this.handleFileContent(fileContent); + this.chatModel.sendMessage("", undefined, fileContent); }; // storage readonly storeFileContent = (fileContent: FileContent): boolean => { - const fileContentPath: string[] = this.getFileContentPath( - fileContent.fileId, - fileContent.fileContentId, - ); + const fileContentPath: string[] = this.getFileContentPath( + fileContent.fileId, + fileContent.fileContentId, + ); - // check if fileContent already exists - const existingFileContent: string | null = - this.storageModel.read(fileContentPath); - if (existingFileContent != null) return false; + // check if fileContent already exists + const existingFileContent: string | null = + this.storageModel.read(fileContentPath); + if (existingFileContent != null) return false; - const stringifiedContent: string = stringify(fileContent); - this.storageModel.write(fileContentPath, stringifiedContent); - return true; + const stringifiedContent: string = stringify(fileContent); + this.storageModel.write(fileContentPath, stringifiedContent); + return true; }; readonly listFileIds = (): string[] => { - return this.storageModel.list(this.basePath); + return this.storageModel.list(this.basePath); }; readonly listFileContentIds = (fileId: string): string[] => { - const filePath: string[] = this.getFilePath(fileId); - return this.storageModel.list(filePath); + const filePath: string[] = this.getFilePath(fileId); + return this.storageModel.list(filePath); }; readonly selectLatestFileContentId = ( - fileContentIds: string[], + fileContentIds: string[], ): string | undefined => { - return fileContentIds[fileContentIds.length - 1]; + return fileContentIds[fileContentIds.length - 1]; }; readonly getFileContent = >( - fileId: string, - fileContentName: string, - reference: T, + fileId: string, + fileContentName: string, + reference: T, ): T | null => { - const filePath: string[] = this.getFileContentPath( - fileId, - fileContentName, - ); - const fileContentOrNull: T | null = this.storageModel.readStringifiable( - filePath, - reference, - ); - return fileContentOrNull; + const filePath: string[] = this.getFileContentPath( + fileId, + fileContentName, + ); + const fileContentOrNull: T | null = this.storageModel.readStringifiable( + filePath, + reference, + ); + return fileContentOrNull; }; readonly getLatestFileContent = >( - fileId: string, - reference: T, + fileId: string, + reference: T, ): T | null => { - const fileContentsIds: string[] = this.listFileContentIds(fileId); - const latestFileContentId: string | undefined = - this.selectLatestFileContentId(fileContentsIds); - if (latestFileContentId == undefined) return null; + const fileContentsIds: string[] = this.listFileContentIds(fileId); + const latestFileContentId: string | undefined = + this.selectLatestFileContentId(fileContentsIds); + if (latestFileContentId == undefined) return null; - const fileContent: T | null = this.getFileContent( - fileId, - latestFileContentId, - reference, - ); - return fileContent; + const fileContent: T | null = this.getFileContent( + fileId, + latestFileContentId, + reference, + ); + return fileContent; }; // init constructor( - storageModel: StorageModel, - settingsModel: SettingsModel, - chatModel: ChatModel, + storageModel: StorageModel, + settingsModel: SettingsModel, + chatModel: ChatModel, ) { - this.chatModel = chatModel; - this.settingsModel = settingsModel; - this.storageModel = storageModel; + this.chatModel = chatModel; + this.settingsModel = settingsModel; + this.storageModel = storageModel; - this.boardsAndTasksModel = new BoardsAndTasksModel( - this.storageModel, - this.settingsModel, - chatModel, - this, - ); + this.boardsAndTasksModel = new BoardsAndTasksModel( + this.storageModel, + this.settingsModel, + chatModel, + this, + ); } // utility static generateFileContentId = (creationDate: string): string => { - return creationDate + v4(); + return creationDate + v4(); }; static createFileContent = ( - fileId: string, - type: T, + fileId: string, + type: T, ): FileContent => { - const creationDate: string = createTimestamp(); - const fileContentId: string = - FileModel.generateFileContentId(creationDate); + const creationDate: string = createTimestamp(); + const fileContentId: string = + FileModel.generateFileContentId(creationDate); - return { - dataVersion: DATA_VERSION, + return { + dataVersion: DATA_VERSION, - fileId, - fileContentId, - creationDate, - type, - }; + fileId, + fileContentId, + creationDate, + type, + }; }; } // paths export enum FileModelSubPath { Data = "data", - Model = "model", - ModelView = "view", - ModelTask = "tasks", - ModelCalendar = "calendar", + Model = "model", + ModelView = "view", + ModelTask = "tasks", + ModelCalendar = "calendar", } // types export interface FileContent extends ValidObject, StringEntryObject { - readonly fileId: string; - readonly fileContentId: string; - readonly creationDate: string; + readonly fileId: string; + readonly fileContentId: string; + readonly creationDate: string; - readonly type: T; -} + readonly type: T; + } // references export const FileContentReference: FileContent = { diff --git a/src/View/keystrokes.ts b/src/View/keystrokes.ts index 1a8b1529..f3014aff 100644 --- a/src/View/keystrokes.ts +++ b/src/View/keystrokes.ts @@ -6,5 +6,5 @@ export enum CommonKeys { CloseOrCancel = "backspace", Apply = "enter", Settings = ",", - Create = ";", + Create = "a", } diff --git a/src/ViewModel/Global/coreViewModel.ts b/src/ViewModel/Global/coreViewModel.ts index 2f1d2f5d..6f2c35a6 100644 --- a/src/ViewModel/Global/coreViewModel.ts +++ b/src/ViewModel/Global/coreViewModel.ts @@ -49,7 +49,9 @@ export default class CoreViewModel { }; handleKeyDown = (e: KeyboardEvent): void => { + if (!(e instanceof KeyboardEvent)) return console.trace("NOT A KEY EVENT"); if (CoreViewModel.checkIsKeystroke(e) == false) return; + console.log(e.key); e.preventDefault(); const contexts: Context[] = this.contexts; while (contexts.length > 0) { diff --git a/src/ViewModel/Pages/boardViewModel.ts b/src/ViewModel/Pages/boardViewModel.ts index 0c9c7b66..805adf0c 100644 --- a/src/ViewModel/Pages/boardViewModel.ts +++ b/src/ViewModel/Pages/boardViewModel.ts @@ -154,6 +154,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel { this, taskFileContent, ); + console.log("STILL HERE", taskFileContent.fileId); this.taskViewModels.set(taskFileContent.fileId, taskViewModel); };