Fix rendering of GIFs

This commit is contained in:
Fedor Indutny 2021-06-24 12:05:27 -07:00 committed by GitHub
parent a053c395a4
commit a7799a74c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 11 deletions

View file

@ -4,7 +4,6 @@
import React, { useRef, useState, useEffect } from 'react'; import React, { useRef, useState, useEffect } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { Blurhash } from 'react-blurhash'; import { Blurhash } from 'react-blurhash';
import formatFileSize from 'filesize';
import { LocalizerType, ThemeType } from '../../types/Util'; import { LocalizerType, ThemeType } from '../../types/Util';
import { Spinner } from '../Spinner'; import { Spinner } from '../Spinner';
@ -170,7 +169,7 @@ export const GIF: React.FC<Props> = props => {
if (isNotDownloaded && attachment.fileSize) { if (isNotDownloaded && attachment.fileSize) {
fileSize = ( fileSize = (
<div className="module-image--gif__filesize"> <div className="module-image--gif__filesize">
{formatFileSize(attachment.fileSize || 0)} · GIF {attachment.fileSize} · GIF
</div> </div>
); );
} }

View file

@ -801,7 +801,7 @@ story.add('Not Downloaded GIF', () => {
contentType: VIDEO_MP4, contentType: VIDEO_MP4,
flags: SignalService.AttachmentPointer.Flags.GIF, flags: SignalService.AttachmentPointer.Flags.GIF,
fileName: 'cat-gif.mp4', fileName: 'cat-gif.mp4',
fileSize: 188610, fileSize: '188.61 KB',
blurHash: 'LDA,FDBnm+I=p{tkIUI;~UkpELV]', blurHash: 'LDA,FDBnm+I=p{tkIUI;~UkpELV]',
width: 400, width: 400,
height: 332, height: 332,
@ -821,7 +821,7 @@ story.add('Pending GIF', () => {
contentType: VIDEO_MP4, contentType: VIDEO_MP4,
flags: SignalService.AttachmentPointer.Flags.GIF, flags: SignalService.AttachmentPointer.Flags.GIF,
fileName: 'cat-gif.mp4', fileName: 'cat-gif.mp4',
fileSize: 188610, fileSize: '188.61 KB',
blurHash: 'LDA,FDBnm+I=p{tkIUI;~UkpELV]', blurHash: 'LDA,FDBnm+I=p{tkIUI;~UkpELV]',
width: 400, width: 400,
height: 332, height: 332,

View file

@ -8,7 +8,6 @@ import {
LastMessageStatus, LastMessageStatus,
MessageAttributesType, MessageAttributesType,
ShallowChallengeError, ShallowChallengeError,
WhatIsThis,
} from '../../model-types.d'; } from '../../model-types.d';
import { TimelineItemType } from '../../components/conversation/TimelineItem'; import { TimelineItemType } from '../../components/conversation/TimelineItem';
@ -940,7 +939,7 @@ export function getPropsForEmbeddedContact(
} }
export function getPropsForAttachment( export function getPropsForAttachment(
attachment: WhatIsThis attachment: AttachmentType
): AttachmentType | null { ): AttachmentType | null {
if (!attachment) { if (!attachment) {
return null; return null;
@ -950,10 +949,12 @@ export function getPropsForAttachment(
return { return {
...attachment, ...attachment,
fileSize: size ? filesize(size) : null, fileSize: size ? filesize(size) : undefined,
isVoiceMessage: isVoiceMessage(attachment), isVoiceMessage: isVoiceMessage(attachment),
pending, pending,
url: path ? window.Signal.Migrations.getAbsoluteAttachmentPath(path) : null, url: path
? window.Signal.Migrations.getAbsoluteAttachmentPath(path)
: undefined,
screenshot: screenshot screenshot: screenshot
? { ? {
...screenshot, ...screenshot,
@ -961,7 +962,7 @@ export function getPropsForAttachment(
screenshot.path screenshot.path
), ),
} }
: null, : undefined,
thumbnail: thumbnail thumbnail: thumbnail
? { ? {
...thumbnail, ...thumbnail,
@ -969,7 +970,7 @@ export function getPropsForAttachment(
thumbnail.path thumbnail.path
), ),
} }
: null, : undefined,
}; };
} }

View file

@ -31,7 +31,7 @@ export type AttachmentType = {
/** For messages not already on disk, this will be a data url */ /** For messages not already on disk, this will be a data url */
url?: string; url?: string;
size?: number; size?: number;
fileSize?: number; fileSize?: string;
pending?: boolean; pending?: boolean;
width?: number; width?: number;
height?: number; height?: number;