add functions to manage and add chat

This commit is contained in:
marlon-erler
2024-07-19 21:10:31 +02:00
parent 14a1031885
commit 58b9d4ea0c
2 changed files with 77 additions and 33 deletions
+20
View File
@@ -41,6 +41,17 @@ export class ChatModel {
return StorageModel.join(this.objectDirPath, id);
}
// set
setPrimaryChannel(primaryChannel: string): void {
this.info.primaryChannel = primaryChannel;
this.storeInfo();
}
setSecondaryChannels(secondaryChannels: string[]): void {
this.info.secondaryChannels = secondaryChannels;
this.storeInfo();
}
// store & add
storeInfo(): void {
this.storageModel.storeStringifiable(this.infoPath, this.info);
@@ -105,6 +116,15 @@ export class ChatModel {
}
// creation methods
export function createChat(storageModel: StorageModel, primaryChannel: string): ChatModel {
const id: string = v4();
const chatModel = new ChatModel(storageModel, id);
chatModel.setPrimaryChannel(primaryChannel);
return chatModel;
}
export function generateChatInfo(primaryChannel: string): ChatInfo {
return {
primaryChannel,