]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Fix media modal crashing when media has no blurhash
authorEugen Rochko <eugen@zeonfederated.com>
Sat, 28 Nov 2020 02:37:01 +0000 (03:37 +0100)
committerClaire <claire.github-309c@sitedethib.com>
Fri, 7 May 2021 20:47:09 +0000 (22:47 +0200)
Port 13206fcfb86844ba4a0c872eaf8c11a61ea848df to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
app/javascript/flavours/glitch/features/ui/components/media_modal.js

index 7b07c557f28acea71e58728e2d78dac3982a6ae0..7290a914aca1f3cb7c34e35edf40697642731a82 100644 (file)
@@ -231,9 +231,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);
+    }
   }
 
   render () {