Fix crash when message attachment does not have images (#2377)

* Fix crash when message attachment does not have images

* optional chaining
This commit is contained in:
Elias Nahum 2018-11-26 20:26:46 -03:00 committed by GitHub
parent a03016a9e3
commit 4925970b86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,7 +37,7 @@ export default class AttachmentImage extends PureComponent {
const {imageUrl, metadata} = this.props;
this.setViewPortMaxWidth();
if (metadata?.images[imageUrl]) {
if (metadata?.images?.[imageUrl]) {
const img = metadata.images[imageUrl];
this.setImageDimensionsFromMeta(null, img);
}
@ -96,7 +96,7 @@ export default class AttachmentImage extends PureComponent {
setImageUrl = (imageURL) => {
const {imageUrl: attachmentImageUrl, metadata} = this.props;
if (metadata?.images[attachmentImageUrl]) {
if (metadata?.images?.[attachmentImageUrl]) {
this.setImageDimensionsFromMeta(imageURL, metadata.images[attachmentImageUrl]);
return;
}