Show download button for pending Link Preview images
This commit is contained in:
parent
98c9992705
commit
529dd1a3cc
2 changed files with 17 additions and 4 deletions
|
@ -847,7 +847,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.module-message__link-preview {
|
.module-message__link-preview {
|
||||||
@include button-reset;
|
cursor: pointer;
|
||||||
|
|
||||||
&--nonclickable {
|
&--nonclickable {
|
||||||
cursor: inherit;
|
cursor: inherit;
|
||||||
|
|
|
@ -846,6 +846,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
|
|
||||||
public renderPreview(): JSX.Element | null {
|
public renderPreview(): JSX.Element | null {
|
||||||
const {
|
const {
|
||||||
|
id,
|
||||||
attachments,
|
attachments,
|
||||||
conversationType,
|
conversationType,
|
||||||
direction,
|
direction,
|
||||||
|
@ -854,6 +855,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
previews,
|
previews,
|
||||||
quote,
|
quote,
|
||||||
theme,
|
theme,
|
||||||
|
kickOffAttachmentDownload,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
// Attachments take precedence over Link Previews
|
// Attachments take precedence over Link Previews
|
||||||
|
@ -889,6 +891,14 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
'module-message__link-preview--nonclickable': !isClickable,
|
'module-message__link-preview--nonclickable': !isClickable,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
const onPreviewImageClick = () => {
|
||||||
|
if (first.image && hasNotDownloaded(first.image)) {
|
||||||
|
kickOffAttachmentDownload({
|
||||||
|
attachment: first.image,
|
||||||
|
messageId: id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
const contents = (
|
const contents = (
|
||||||
<>
|
<>
|
||||||
{first.image && previewHasImage && isFullSizeImage ? (
|
{first.image && previewHasImage && isFullSizeImage ? (
|
||||||
|
@ -899,6 +909,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
onError={this.handleImageError}
|
onError={this.handleImageError}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
|
onClick={onPreviewImageClick}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="module-message__link-preview__content">
|
<div className="module-message__link-preview__content">
|
||||||
|
@ -916,6 +927,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
attachment={first.image}
|
attachment={first.image}
|
||||||
onError={this.handleImageError}
|
onError={this.handleImageError}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
|
onClick={onPreviewImageClick}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -950,8 +962,9 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
);
|
);
|
||||||
|
|
||||||
return isClickable ? (
|
return isClickable ? (
|
||||||
<button
|
<div
|
||||||
type="button"
|
role="link"
|
||||||
|
tabIndex={0}
|
||||||
className={className}
|
className={className}
|
||||||
onKeyDown={(event: React.KeyboardEvent) => {
|
onKeyDown={(event: React.KeyboardEvent) => {
|
||||||
if (event.key === 'Enter' || event.key === 'Space') {
|
if (event.key === 'Enter' || event.key === 'Space') {
|
||||||
|
@ -969,7 +982,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{contents}
|
{contents}
|
||||||
</button>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className={className}>{contents}</div>
|
<div className={className}>{contents}</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue