Ensure non-visual attachments can be manually downloaded

This commit is contained in:
Scott Nonnenberg 2022-08-31 15:32:06 -07:00 committed by GitHub
parent dda21701c5
commit 1cb70547fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 3 deletions

View File

@ -975,7 +975,10 @@ export class Message extends React.PureComponent<Props, State> {
if (
isImage(attachments) ||
(isVideo(attachments) && hasVideoScreenshot(attachments))
(isVideo(attachments) &&
(!isDownloaded(attachments[0]) ||
!attachments?.[0].pending ||
hasVideoScreenshot(attachments)))
) {
const bottomOverlay = !isSticker && !collapseMetadata;
// We only want users to tab into this if there's more than one
@ -1082,7 +1085,16 @@ export class Message extends React.PureComponent<Props, State> {
)}
// There's only ever one of these, so we don't want users to tab into it
tabIndex={-1}
onClick={this.openGenericAttachment}
onClick={() => {
if (!isDownloaded(firstAttachment)) {
kickOffAttachmentDownload({
attachment: firstAttachment,
messageId: id,
});
} else {
this.openGenericAttachment();
}
}}
>
{pending ? (
<div className="module-message__generic-attachment__spinner-container">
@ -2736,7 +2748,6 @@ export class Message extends React.PureComponent<Props, State> {
attachments &&
attachments.length > 0 &&
!isAttachmentPending &&
(isImage(attachments) || isVideo(attachments)) &&
!isDownloaded(attachments[0])
) {
event.preventDefault();