]> cat aescling's git repositories - mastodon.git/commitdiff
Fix front-end crash when a video has a blurhash and is hidden behind a CW
authorThibaut Girka <thib@sitedethib.com>
Tue, 7 May 2019 20:12:11 +0000 (22:12 +0200)
committerThibG <thib@sitedethib.com>
Tue, 7 May 2019 20:33:37 +0000 (22:33 +0200)
app/javascript/flavours/glitch/features/video/index.js

index 8291ff3c81f15912d8e2a8aae352f16fca4f4137..2e0d59d4736de8bc540b0f0e470bba847aa24c55 100644 (file)
@@ -166,6 +166,10 @@ export default class Video extends React.PureComponent {
 
   setCanvasRef = c => {
     this.canvas = c;
+
+    if (c && this.props.blurhash) {
+      this._decode();
+    }
   }
 
   handleMouseDownRoot = e => {
@@ -310,6 +314,8 @@ export default class Video extends React.PureComponent {
   }
 
   _decode () {
+    if (!this.canvas) return;
+
     const hash   = this.props.blurhash;
     const pixels = decode(hash, 32, 32);