Files
CT/src/Model/fileModel.ts
T

43 lines
830 B
TypeScript
Raw Normal View History

2024-07-21 21:41:19 +02:00
// this file is responsible for managing files within chats.
import ChatModel, { ChatMessage } from "./chatModel";
import { parseValidObject } from "./Utility/utility";
2024-07-21 21:45:18 +02:00
export default class FileModel {
chatModel: ChatModel;
// handler
handleStringifiedFile = (stringifiedFile: string): void => {
const file: File | null = parseValidObject<File>(stringifiedFile);
if (file == null) return;
};
// methods
addFile = (file: File): void => {
this.chatModel.sendMessage("", file);
};
2024-07-21 21:45:18 +02:00
// init
constructor(chatModel: ChatModel) {
this.chatModel = chatModel;
}
}
2024-07-21 21:41:19 +02:00
// types
2024-07-21 20:54:18 +02:00
export interface File {
dataVersion: "v2";
id: string;
title: string;
contentVersions: { [id: string]: FileContent };
}
export interface FileContent {
dataVersion: "v2";
id: string;
creationDate: string;
}