From 529dd1a3cc5f34b99572b7d1ce6006987d96d092 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Mon, 15 Mar 2021 15:57:02 -0700 Subject: [PATCH] Show download button for pending Link Preview images --- stylesheets/_modules.scss | 2 +- ts/components/conversation/Message.tsx | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/stylesheets/_modules.scss b/stylesheets/_modules.scss index 96257fa62..c217e3fd0 100644 --- a/stylesheets/_modules.scss +++ b/stylesheets/_modules.scss @@ -847,7 +847,7 @@ } .module-message__link-preview { - @include button-reset; + cursor: pointer; &--nonclickable { cursor: inherit; diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index d1cbc004e..37f4f76f7 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -846,6 +846,7 @@ export class Message extends React.PureComponent { public renderPreview(): JSX.Element | null { const { + id, attachments, conversationType, direction, @@ -854,6 +855,7 @@ export class Message extends React.PureComponent { previews, quote, theme, + kickOffAttachmentDownload, } = this.props; // Attachments take precedence over Link Previews @@ -889,6 +891,14 @@ export class Message extends React.PureComponent { 'module-message__link-preview--nonclickable': !isClickable, } ); + const onPreviewImageClick = () => { + if (first.image && hasNotDownloaded(first.image)) { + kickOffAttachmentDownload({ + attachment: first.image, + messageId: id, + }); + } + }; const contents = ( <> {first.image && previewHasImage && isFullSizeImage ? ( @@ -899,6 +909,7 @@ export class Message extends React.PureComponent { onError={this.handleImageError} i18n={i18n} theme={theme} + onClick={onPreviewImageClick} /> ) : null}
@@ -916,6 +927,7 @@ export class Message extends React.PureComponent { attachment={first.image} onError={this.handleImageError} i18n={i18n} + onClick={onPreviewImageClick} />
) : null} @@ -950,8 +962,9 @@ export class Message extends React.PureComponent { ); return isClickable ? ( - + ) : (
{contents}
);