apply checkMatchesObjectStructure in models

This commit is contained in:
marlon-erler
2024-07-22 01:38:08 +02:00
parent 3c8245fca0
commit d85ced4e36
5 changed files with 38 additions and 32 deletions
+7 -5
View File
@@ -1,10 +1,10 @@
// this file is responsible for managing files within chats.
import ChatModel, { ChatMessage } from "./chatModel";
import { DATA_VERSION, ValidObject } from "./Utility/typeSafety";
import StorageModel, { storageKeys } from "./storageModel";
import { parseValidObject, stringify } from "./Utility/utility";
import ChatModel from "./chatModel";
import { v4 } from "uuid";
export default class FileModel {
@@ -58,8 +58,10 @@ export default class FileModel {
getFile = (fileId: string): File | null => {
const filePath = FileModel.getFilePath(fileId);
const fileOrNull: File | null =
this.storageModel.readStringifiable<File>(filePath);
const fileOrNull: File | null = this.storageModel.readStringifiable(
filePath,
FileReference
);
return fileOrNull;
};
@@ -73,7 +75,7 @@ export default class FileModel {
): FileContent | null => {
const filePath = FileModel.getFileContentPath(file, fileContentName);
const fileContentOrNull: FileContent | null =
this.storageModel.readStringifiable<FileContent>(filePath);
this.storageModel.readStringifiable(filePath, FileContentReference);
return fileContentOrNull;
};
@@ -138,4 +140,4 @@ export const FileReference: File = {
id: "",
contentVersions: [FileContentReference],
};
};