Moves DraftAttachments into redux
This commit is contained in:
parent
f81f61af4e
commit
1c3c971cf4
20 changed files with 818 additions and 444 deletions
29
ts/util/writeDraftAttachment.ts
Normal file
29
ts/util/writeDraftAttachment.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { omit } from 'lodash';
|
||||
import { AttachmentType } from '../types/Attachment';
|
||||
|
||||
export async function writeDraftAttachment(
|
||||
attachment: AttachmentType
|
||||
): Promise<AttachmentType> {
|
||||
if (attachment.pending) {
|
||||
throw new Error('writeDraftAttachment: Cannot write pending attachment');
|
||||
}
|
||||
|
||||
const result: AttachmentType = {
|
||||
...omit(attachment, ['data', 'screenshotData']),
|
||||
pending: false,
|
||||
};
|
||||
if (attachment.data) {
|
||||
result.path = await window.Signal.Migrations.writeNewDraftData(
|
||||
attachment.data
|
||||
);
|
||||
}
|
||||
if (attachment.screenshotData) {
|
||||
result.screenshotPath = await window.Signal.Migrations.writeNewDraftData(
|
||||
attachment.screenshotData
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue