Fix media modal crashing when media has no blurhash (#15229)

master
Eugen Rochko 4 years ago committed by GitHub
parent e7f1439b97
commit 13206fcfb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/javascript/mastodon/features/ui/components/media_modal.js

@ -221,10 +221,13 @@ class MediaModal extends ImmutablePureComponent {
_sendBackgroundColor () {
const { media, onChangeBackgroundColor } = this.props;
const index = this.getIndex();
const backgroundColor = decodeRGB(decode83(media.getIn([index, 'blurhash']).slice(2, 6)));
const blurhash = media.getIn([index, 'blurhash']);
if (blurhash) {
const backgroundColor = decodeRGB(decode83(blurhash.slice(2, 6)));
onChangeBackgroundColor(backgroundColor);
}
}
componentWillUnmount () {
window.removeEventListener('keydown', this.handleKeyDown);

Loading…
Cancel
Save