From 30c986027451e069f5844a5c1ff1475cdd793f1a Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 23 Aug 2021 16:48:39 -0600 Subject: [PATCH] Ensure blurhash is treated as optional Fixes https://github.com/vector-im/element-web/issues/18702 --- src/components/views/messages/MImageBody.tsx | 4 ++-- src/components/views/messages/MStickerBody.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/messages/MImageBody.tsx b/src/components/views/messages/MImageBody.tsx index 286d420c58..8ead8d9ba2 100644 --- a/src/components/views/messages/MImageBody.tsx +++ b/src/components/views/messages/MImageBody.tsx @@ -393,7 +393,7 @@ export default class MImageBody extends React.Component { 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. @@ -446,7 +446,7 @@ export default class MImageBody extends React.Component { // 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') { diff --git a/src/components/views/messages/MStickerBody.tsx b/src/components/views/messages/MStickerBody.tsx index 61be246ed9..365426245d 100644 --- a/src/components/views/messages/MStickerBody.tsx +++ b/src/components/views/messages/MStickerBody.tsx @@ -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 ; }