Adds logic around downloading stories

This commit is contained in:
Josh Perez 2022-03-28 21:10:08 -04:00 committed by GitHub
parent 9d3f0072a5
commit 3b5cc26fec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 645 additions and 149 deletions

View file

@ -10,7 +10,7 @@ import { Spinner } from '../Spinner';
import type { AttachmentType } from '../../types/Attachment';
import {
hasNotDownloaded,
hasNotResolved,
getImageDimensions,
defaultBlurHash,
} from '../../types/Attachment';
@ -166,10 +166,10 @@ export const GIF: React.FC<Props> = props => {
};
const isPending = Boolean(attachment.pending);
const isNotDownloaded = hasNotDownloaded(attachment) && !isPending;
const isNotResolved = hasNotResolved(attachment) && !isPending;
let fileSize: JSX.Element | undefined;
if (isNotDownloaded && attachment.fileSize) {
if (isNotResolved && attachment.fileSize) {
fileSize = (
<div className="module-image--gif__filesize">
{attachment.fileSize} · GIF
@ -178,7 +178,7 @@ export const GIF: React.FC<Props> = props => {
}
let gif: JSX.Element | undefined;
if (isNotDownloaded || isPending) {
if (isNotResolved || isPending) {
gif = (
<Blurhash
hash={attachment.blurHash || defaultBlurHash(theme)}
@ -213,12 +213,12 @@ export const GIF: React.FC<Props> = props => {
}
let overlay: JSX.Element | undefined;
if ((tapToPlay && !isPlaying) || isNotDownloaded) {
if ((tapToPlay && !isPlaying) || isNotResolved) {
const className = classNames([
'module-image__border-overlay',
'module-image__border-overlay--with-click-handler',
'module-image--soft-corners',
isNotDownloaded
isNotResolved
? 'module-image--not-downloaded'
: 'module-image--tap-to-play',
]);