remove more object stuff, prepare FileModel

This commit is contained in:
marlon-erler
2024-07-21 20:54:18 +02:00
parent d30bf9d891
commit 920de98e22
3 changed files with 22 additions and 64 deletions
+2 -55
View File
@@ -44,18 +44,10 @@ export class ChatModel {
return storageKeys.chatMessages(this.id);
}
get objectDirPath(): string[] {
return storageKeys.chatObjects(this.id);
}
getMessagePath = (id: string): string[] => {
return [...this.messageDirPath, id];
};
getObjectPath = (id: string): string[] => {
return [...this.objectDirPath, id];
};
// set
setPrimaryChannel = (primaryChannel: string): void => {
this.info.primaryChannel = primaryChannel;
@@ -95,11 +87,6 @@ export class ChatModel {
this.chatMessageHandler(chatMessage);
};
addObject = (chatObject: ChatObject): void => {
const objectPath: string[] = this.getObjectPath(chatObject.id);
this.storageModel.storeStringifiable(objectPath, chatObject);
};
// delete
delete = () => {
// untrack
@@ -149,23 +136,6 @@ export class ChatModel {
return sorted;
}
get objects(): ChatObject[] {
const objectIds: string[] = this.storageModel.list(this.objectDirPath);
if (!Array.isArray(objectIds)) return [];
const objects: ChatObject[] = [];
for (const objectId of objectIds) {
const objectPathComponents: string[] = this.getObjectPath(objectId);
const object: any =
this.storageModel.restoreStringifiable(objectPathComponents);
if (checkIsValidObject(object) == false) continue;
if (object.id != objectId) continue;
objects.push(object);
}
return objects;
}
// messaging
sendMessage = async (body: string): Promise<boolean> => {
const senderName = this.settingsModel.username;
@@ -309,28 +279,5 @@ export interface ChatMessage {
status?: ChatMessageStatus;
stringifiedObject?: string;
}
export interface ChatObject {
dataVersion: "v2";
id: string;
title: string;
contentVersions: { [key: string]: ChatObjectContent };
}
export interface ChatObjectContent {
dataVersion: "v2";
id: string;
creationDate: string;
noteText?: string;
priority?: number;
category?: string;
status?: string;
date?: string;
time?: string;
}
stringifiedFile?: string;
}