Skip to content

Commit

Permalink
Fix rendering of GIFs
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny-signal committed Jun 24, 2021
1 parent a053c39 commit a7799a7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
3 changes: 1 addition & 2 deletions ts/components/conversation/GIF.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import React, { useRef, useState, useEffect } from 'react';
import classNames from 'classnames';
import { Blurhash } from 'react-blurhash';
import formatFileSize from 'filesize';

import { LocalizerType, ThemeType } from '../../types/Util';
import { Spinner } from '../Spinner';
Expand Down Expand Up @@ -170,7 +169,7 @@ export const GIF: React.FC<Props> = props => {
if (isNotDownloaded && attachment.fileSize) {
fileSize = (
<div className="module-image--gif__filesize">
{formatFileSize(attachment.fileSize || 0)} · GIF
{attachment.fileSize} · GIF
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions ts/components/conversation/Message.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ story.add('Not Downloaded GIF', () => {
contentType: VIDEO_MP4,
flags: SignalService.AttachmentPointer.Flags.GIF,
fileName: 'cat-gif.mp4',
fileSize: 188610,
fileSize: '188.61 KB',
blurHash: 'LDA,FDBnm+I=p{tkIUI;~UkpELV]',
width: 400,
height: 332,
Expand All @@ -821,7 +821,7 @@ story.add('Pending GIF', () => {
contentType: VIDEO_MP4,
flags: SignalService.AttachmentPointer.Flags.GIF,
fileName: 'cat-gif.mp4',
fileSize: 188610,
fileSize: '188.61 KB',
blurHash: 'LDA,FDBnm+I=p{tkIUI;~UkpELV]',
width: 400,
height: 332,
Expand Down
13 changes: 7 additions & 6 deletions ts/state/selectors/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
LastMessageStatus,
MessageAttributesType,
ShallowChallengeError,
WhatIsThis,
} from '../../model-types.d';

import { TimelineItemType } from '../../components/conversation/TimelineItem';
Expand Down Expand Up @@ -940,7 +939,7 @@ export function getPropsForEmbeddedContact(
}

export function getPropsForAttachment(
attachment: WhatIsThis
attachment: AttachmentType
): AttachmentType | null {
if (!attachment) {
return null;
Expand All @@ -950,26 +949,28 @@ export function getPropsForAttachment(

return {
...attachment,
fileSize: size ? filesize(size) : null,
fileSize: size ? filesize(size) : undefined,
isVoiceMessage: isVoiceMessage(attachment),
pending,
url: path ? window.Signal.Migrations.getAbsoluteAttachmentPath(path) : null,
url: path
? window.Signal.Migrations.getAbsoluteAttachmentPath(path)
: undefined,
screenshot: screenshot
? {
...screenshot,
url: window.Signal.Migrations.getAbsoluteAttachmentPath(
screenshot.path
),
}
: null,
: undefined,
thumbnail: thumbnail
? {
...thumbnail,
url: window.Signal.Migrations.getAbsoluteAttachmentPath(
thumbnail.path
),
}
: null,
: undefined,
};
}

Expand Down
2 changes: 1 addition & 1 deletion ts/types/Attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type AttachmentType = {
/** For messages not already on disk, this will be a data url */
url?: string;
size?: number;
fileSize?: number;
fileSize?: string;
pending?: boolean;
width?: number;
height?: number;
Expand Down

0 comments on commit a7799a7

Please sign in to comment.