From bfed7dd5f3127f08ece3070bd67f5737933bac1a Mon Sep 17 00:00:00 2001
From: ThibG <thib@sitedethib.com>
Date: Wed, 15 Jul 2020 21:07:53 +0200
Subject: [PATCH] Fix error when closing a playing audio or video modal
 (#14310)

---
 app/javascript/mastodon/features/audio/index.js | 2 ++
 app/javascript/mastodon/features/video/index.js | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/app/javascript/mastodon/features/audio/index.js b/app/javascript/mastodon/features/audio/index.js
index 2f85ebb7e3..1ab1c3117d 100644
--- a/app/javascript/mastodon/features/audio/index.js
+++ b/app/javascript/mastodon/features/audio/index.js
@@ -298,6 +298,8 @@ class Audio extends React.PureComponent {
 
   _renderCanvas () {
     requestAnimationFrame(() => {
+      if (!this.audio) return;
+
       this.handleTimeUpdate();
       this._clear();
       this._draw();
diff --git a/app/javascript/mastodon/features/video/index.js b/app/javascript/mastodon/features/video/index.js
index fb12567f0d..99dcdca221 100644
--- a/app/javascript/mastodon/features/video/index.js
+++ b/app/javascript/mastodon/features/video/index.js
@@ -182,6 +182,8 @@ class Video extends React.PureComponent {
 
   _updateTime () {
     requestAnimationFrame(() => {
+      if (!this.video) return;
+
       this.handleTimeUpdate();
 
       if (!this.state.paused) {
-- 
GitLab