chat attachment is now related to single message

This commit is contained in:
josc146
2023-11-05 21:05:06 +08:00
parent 64826b9af7
commit 37dda4333d
2 changed files with 59 additions and 29 deletions

View File

@@ -31,6 +31,12 @@ export type Status = {
device_name: string;
}
export type Attachment = {
name: string;
size: number;
content: string;
}
export type Platform = 'windows' | 'darwin' | 'linux';
class CommonStore {
@@ -53,9 +59,8 @@ class CommonStore {
conversationOrder: string[] = [];
activePreset: Preset | null = null;
attachmentUploading: boolean = false;
attachmentName: string = '';
attachmentSize: number = 0;
attachmentContent: string = '';
attachments: { [uuid: string]: Attachment[] } = {};
currentTempAttachment: Attachment | null = null;
// completion
completionPreset: CompletionPreset | null = null;
completionGenerating: boolean = false;
@@ -332,16 +337,19 @@ class CommonStore {
this.attachmentUploading = value;
}
setAttachmentName(value: string) {
this.attachmentName = value;
setAttachments(value: { [uuid: string]: Attachment[] }) {
this.attachments = value;
}
setAttachmentSize(value: number) {
this.attachmentSize = value;
setAttachment(uuid: string, value: Attachment[] | null) {
if (value === null)
delete this.attachments[uuid];
else
this.attachments[uuid] = value;
}
setAttachmentContent(value: string) {
this.attachmentContent = value;
setCurrentTempAttachment(value: Attachment | null) {
this.currentTempAttachment = value;
}
}