From d7ec22fb0b36c684b01c573a3fe5adb65db6a48f Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Fri, 19 Mar 2021 11:47:57 -0700 Subject: [PATCH] Save attachment button should download attachment if needed --- ts/components/conversation/Message.tsx | 31 +++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index 8894788d5..fc4dc740f 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -796,20 +796,7 @@ export class Message extends React.PureComponent { )} // There's only ever one of these, so we don't want users to tab into it tabIndex={-1} - onClick={(event: React.MouseEvent) => { - event.stopPropagation(); - event.preventDefault(); - - if (hasNotDownloaded(firstAttachment)) { - kickOffAttachmentDownload({ - attachment: firstAttachment, - messageId: id, - }); - return; - } - - this.openGenericAttachment(); - }} + onClick={this.openGenericAttachment} > {pending ? (
@@ -2097,7 +2084,13 @@ export class Message extends React.PureComponent { }; public openGenericAttachment = (event?: React.MouseEvent): void => { - const { attachments, downloadAttachment, timestamp } = this.props; + const { + id, + attachments, + downloadAttachment, + timestamp, + kickOffAttachmentDownload, + } = this.props; if (event) { event.preventDefault(); @@ -2109,6 +2102,14 @@ export class Message extends React.PureComponent { } const attachment = attachments[0]; + if (hasNotDownloaded(attachment)) { + kickOffAttachmentDownload({ + attachment, + messageId: id, + }); + return; + } + const { fileName } = attachment; const isDangerous = isFileDangerous(fileName || '');