2024-07-21 21:41:19 +02:00
|
|
|
// this file is responsible for managing files within chats.
|
|
|
|
|
|
2024-07-21 22:42:32 +02:00
|
|
|
import ChatModel, { ChatMessage } from "./chatModel";
|
|
|
|
|
|
|
|
|
|
import { parseValidObject } from "./Utility/utility";
|
2024-07-21 21:45:18 +02:00
|
|
|
|
|
|
|
|
export default class FileModel {
|
|
|
|
|
chatModel: ChatModel;
|
|
|
|
|
|
2024-07-21 22:42:32 +02:00
|
|
|
// 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;
|
|
|
|
|
}
|