]> cat aescling's git repositories - mastodon.git/commitdiff
Fix new audio player when under content warnings
authorThibaut Girka <thib@sitedethib.com>
Tue, 11 Aug 2020 19:01:37 +0000 (21:01 +0200)
committerThibG <thib@sitedethib.com>
Tue, 11 Aug 2020 20:37:51 +0000 (22:37 +0200)
app/javascript/flavours/glitch/features/audio/index.js

index f2c2fe4e0cdfe5fe5432d3366d58d204860154b7..7a2fb7fb6cff9169d2d4cb8e113384b6982d2857 100644 (file)
@@ -68,11 +68,13 @@ class Audio extends React.PureComponent {
     const width  = this.player.offsetWidth;
     const height = this.props.fullscreen ? this.player.offsetHeight : (width / (16/9));
 
-    if (this.props.cacheWidth) {
-      this.props.cacheWidth(width);
-    }
+    if (width && width != this.state.containerWidth) {
+      if (this.props.cacheWidth) {
+        this.props.cacheWidth(width);
+      }
 
-    this.setState({ width, height });
+      this.setState({ width, height });
+    }
   }
 
   setSeekRef = c => {
@@ -102,6 +104,10 @@ class Audio extends React.PureComponent {
   }
 
   componentDidUpdate (prevProps, prevState) {
+    if (this.player) {
+      this._setDimensions();
+    }
+
     if (prevProps.src !== this.props.src || this.state.width !== prevState.width || this.state.height !== prevState.height || prevProps.accentColor !== this.props.accentColor) {
       this._clear();
       this._draw();