Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6661 from matrix-org/travis/blurhash-opt
Browse files Browse the repository at this point in the history
Ensure blurhash is treated as optional
  • Loading branch information
turt2live committed Aug 24, 2021
2 parents 924983d + 30c9860 commit 52e1884
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/views/messages/MImageBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {

const classes = classNames({
'mx_MImageBody_thumbnail': true,
'mx_MImageBody_thumbnail--blurhash': this.props.mxEvent.getContent().info[BLURHASH_FIELD],
'mx_MImageBody_thumbnail--blurhash': this.props.mxEvent.getContent().info?.[BLURHASH_FIELD],
});

// This has incredibly broken types.
Expand Down Expand Up @@ -446,7 +446,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {

// Overidden by MStickerBody
protected getPlaceholder(width: number, height: number): JSX.Element {
const blurhash = this.props.mxEvent.getContent().info[BLURHASH_FIELD];
const blurhash = this.props.mxEvent.getContent().info?.[BLURHASH_FIELD];

if (blurhash) {
if (this.state.placeholder === 'no-image') {
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/messages/MStickerBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class MStickerBody extends MImageBody {
// Placeholder to show in place of the sticker image if
// img onLoad hasn't fired yet.
protected getPlaceholder(width: number, height: number): JSX.Element {
if (this.props.mxEvent.getContent().info[BLURHASH_FIELD]) return super.getPlaceholder(width, height);
if (this.props.mxEvent.getContent().info?.[BLURHASH_FIELD]) return super.getPlaceholder(width, height);
return <img src={require("../../../../res/img/icons-show-stickers.svg")} width="75" height="75" />;
}

Expand Down

0 comments on commit 52e1884

Please sign in to comment.