mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-18 23:49:20 +01:00
Receive support for editing messages
This commit is contained in:
@@ -824,7 +824,8 @@ export const deleteAllExternalFiles = ({
|
||||
}
|
||||
|
||||
return async (message: MessageAttributesType) => {
|
||||
const { attachments, quote, contact, preview, sticker } = message;
|
||||
const { attachments, editHistory, quote, contact, preview, sticker } =
|
||||
message;
|
||||
|
||||
if (attachments && attachments.length) {
|
||||
await Promise.all(attachments.map(deleteAttachmentData));
|
||||
@@ -858,15 +859,7 @@ export const deleteAllExternalFiles = ({
|
||||
}
|
||||
|
||||
if (preview && preview.length) {
|
||||
await Promise.all(
|
||||
preview.map(async item => {
|
||||
const { image } = item;
|
||||
|
||||
if (image && image.path) {
|
||||
await deleteOnDisk(image.path);
|
||||
}
|
||||
})
|
||||
);
|
||||
await deletePreviews(preview, deleteOnDisk);
|
||||
}
|
||||
|
||||
if (sticker && sticker.data && sticker.data.path) {
|
||||
@@ -876,9 +869,42 @@ export const deleteAllExternalFiles = ({
|
||||
await deleteOnDisk(sticker.data.thumbnail.path);
|
||||
}
|
||||
}
|
||||
|
||||
if (editHistory && editHistory.length) {
|
||||
await editHistory.map(edit => {
|
||||
if (!edit.attachments || !edit.attachments.length) {
|
||||
return;
|
||||
}
|
||||
return Promise.all(edit.attachments.map(deleteAttachmentData));
|
||||
});
|
||||
await editHistory.map(edit => deletePreviews(edit.preview, deleteOnDisk));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
async function deletePreviews(
|
||||
preview: MessageAttributesType['preview'],
|
||||
deleteOnDisk: (path: string) => Promise<void>
|
||||
): Promise<Array<void>> {
|
||||
if (!preview) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Promise.all(
|
||||
preview.map(async item => {
|
||||
const { image } = item;
|
||||
|
||||
if (image && image.path) {
|
||||
await deleteOnDisk(image.path);
|
||||
}
|
||||
|
||||
if (image?.thumbnail?.path) {
|
||||
await deleteOnDisk(image.thumbnail.path);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// createAttachmentDataWriter :: (RelativePath -> IO Unit)
|
||||
// Message ->
|
||||
// IO (Promise Message)
|
||||
|
||||
Reference in New Issue
Block a user