Moves DraftAttachments into redux
This commit is contained in:
parent
f81f61af4e
commit
1c3c971cf4
20 changed files with 818 additions and 444 deletions
40
ts/util/resolveAttachmentOnDisk.ts
Normal file
40
ts/util/resolveAttachmentOnDisk.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { pick } from 'lodash';
|
||||
|
||||
import * as log from '../logging/log';
|
||||
import { AttachmentType } from '../types/Attachment';
|
||||
|
||||
export function resolveAttachmentOnDisk(
|
||||
attachment: AttachmentType
|
||||
): AttachmentType {
|
||||
let url = '';
|
||||
if (attachment.pending) {
|
||||
return attachment;
|
||||
}
|
||||
|
||||
if (attachment.screenshotPath) {
|
||||
url = window.Signal.Migrations.getAbsoluteDraftPath(
|
||||
attachment.screenshotPath
|
||||
);
|
||||
} else if (attachment.path) {
|
||||
url = window.Signal.Migrations.getAbsoluteDraftPath(attachment.path);
|
||||
} else {
|
||||
log.warn(
|
||||
'resolveOnDiskAttachment: Attachment was missing both screenshotPath and path fields'
|
||||
);
|
||||
}
|
||||
return {
|
||||
...pick(attachment, [
|
||||
'blurHash',
|
||||
'caption',
|
||||
'contentType',
|
||||
'fileName',
|
||||
'path',
|
||||
'size',
|
||||
]),
|
||||
pending: false,
|
||||
url,
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue