Properly remove data
from written draft attachments
This commit is contained in:
parent
eed873d4e0
commit
bf25a5db0b
1 changed files with 10 additions and 24 deletions
|
@ -2089,37 +2089,23 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||||
async writeDraftAttachment(
|
async writeDraftAttachment(
|
||||||
attachment: InMemoryAttachmentDraftType
|
attachment: InMemoryAttachmentDraftType
|
||||||
): Promise<OnDiskAttachmentDraftType> {
|
): Promise<OnDiskAttachmentDraftType> {
|
||||||
let toWrite: OnDiskAttachmentDraftType | undefined;
|
|
||||||
|
|
||||||
if (attachment.pending) {
|
if (attachment.pending) {
|
||||||
throw new Error('writeDraftAttachment: Cannot write pending attachment');
|
throw new Error('writeDraftAttachment: Cannot write pending attachment');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const result: OnDiskAttachmentDraftType = {
|
||||||
|
...omit(attachment, ['data', 'screenshotData']),
|
||||||
|
pending: false,
|
||||||
|
};
|
||||||
if (attachment.data) {
|
if (attachment.data) {
|
||||||
const path = await writeNewDraftData(attachment.data);
|
result.path = await writeNewDraftData(attachment.data);
|
||||||
toWrite = {
|
|
||||||
...omit(attachment, ['data']),
|
|
||||||
path,
|
|
||||||
pending: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attachment.pending) {
|
|
||||||
throw new Error('writeDraftAttachment: Cannot write pending attachment');
|
|
||||||
}
|
}
|
||||||
if (attachment.screenshotData) {
|
if (attachment.screenshotData) {
|
||||||
const screenshotPath = await writeNewDraftData(attachment.screenshotData);
|
result.screenshotPath = await writeNewDraftData(
|
||||||
toWrite = {
|
attachment.screenshotData
|
||||||
...omit(attachment, ['screenshotData']),
|
);
|
||||||
screenshotPath,
|
|
||||||
pending: false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
if (!toWrite) {
|
|
||||||
throw new Error('writeDraftAttachment: Neither data nor screenshotData!');
|
|
||||||
}
|
|
||||||
|
|
||||||
return toWrite;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async maybeAddAttachment(file: File): Promise<void> {
|
async maybeAddAttachment(file: File): Promise<void> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue