about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2020-11-28 03:37:01 +0100
committerGitHub <noreply@github.com>2020-11-28 03:37:01 +0100
commit13206fcfb86844ba4a0c872eaf8c11a61ea848df (patch)
treea00c1c3e32561f723fbab3aeb97d1692faa261db
parente7f1439b9748f5adb85fcb0807376855a90220c4 (diff)
Fix media modal crashing when media has no blurhash (#15229)
-rw-r--r--app/javascript/mastodon/features/ui/components/media_modal.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/javascript/mastodon/features/ui/components/media_modal.js b/app/javascript/mastodon/features/ui/components/media_modal.js
index bcec19a49..58cef1e9d 100644
--- a/app/javascript/mastodon/features/ui/components/media_modal.js
+++ b/app/javascript/mastodon/features/ui/components/media_modal.js
@@ -221,9 +221,12 @@ 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']);
 
-    onChangeBackgroundColor(backgroundColor);
+    if (blurhash) {
+      const backgroundColor = decodeRGB(decode83(blurhash.slice(2, 6)));
+      onChangeBackgroundColor(backgroundColor);
+    }
   }
 
   componentWillUnmount () {