Support for single-attachment delete synced across devices
This commit is contained in:
parent
97229e2e65
commit
ac04d02d4f
26 changed files with 422 additions and 55 deletions
|
@ -2,6 +2,7 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { ThunkAction } from 'redux-thunk';
|
||||
import { v4 as generateUuid } from 'uuid';
|
||||
|
||||
import type { ReadonlyDeep } from 'type-fest';
|
||||
import * as log from '../../logging/log';
|
||||
|
@ -172,6 +173,7 @@ export function completeRecording(
|
|||
|
||||
const voiceNoteAttachment: InMemoryAttachmentDraftType = {
|
||||
pending: false,
|
||||
clientUuid: generateUuid(),
|
||||
contentType: stringToMIMEType(blob.type),
|
||||
data,
|
||||
size: data.byteLength,
|
||||
|
|
|
@ -799,6 +799,7 @@ function addAttachment(
|
|||
// We do async operations first so multiple in-process addAttachments don't stomp on
|
||||
// each other.
|
||||
const onDisk = await writeDraftAttachment(attachment);
|
||||
const toAdd = { ...onDisk, clientUuid: generateUuid() };
|
||||
|
||||
const state = getState();
|
||||
|
||||
|
@ -822,7 +823,7 @@ function addAttachment(
|
|||
|
||||
// User has canceled the draft so we don't need to continue processing
|
||||
if (!hasDraftAttachmentPending) {
|
||||
await deleteDraftAttachment(onDisk);
|
||||
await deleteDraftAttachment(toAdd);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -835,9 +836,9 @@ function addAttachment(
|
|||
log.warn(
|
||||
`addAttachment: Failed to find pending attachment with path ${attachment.path}`
|
||||
);
|
||||
nextAttachments = [...draftAttachments, onDisk];
|
||||
nextAttachments = [...draftAttachments, toAdd];
|
||||
} else {
|
||||
nextAttachments = replaceIndex(draftAttachments, index, onDisk);
|
||||
nextAttachments = replaceIndex(draftAttachments, index, toAdd);
|
||||
}
|
||||
|
||||
replaceAttachments(conversationId, nextAttachments)(
|
||||
|
@ -1165,6 +1166,7 @@ function getPendingAttachment(file: File): AttachmentDraftType | undefined {
|
|||
|
||||
return {
|
||||
contentType: fileType,
|
||||
clientUuid: generateUuid(),
|
||||
fileName,
|
||||
size: file.size,
|
||||
path: file.name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue