]> cat aescling's git repositories - mastodon.git/commitdiff
Adjust scroll if previewCard appeared
authorThibaut Girka <thib@sitedethib.com>
Sat, 9 Feb 2019 20:24:43 +0000 (21:24 +0100)
committerThibG <thib@sitedethib.com>
Sun, 10 Feb 2019 21:54:25 +0000 (22:54 +0100)
app/javascript/flavours/glitch/components/status.js

index 68788451b0be697c74b582bdccfdbcc12de14518..1a5cb4a975fa1ee23c1ef805fede5573944619c8 100644 (file)
@@ -216,6 +216,8 @@ export default class Status extends ImmutablePureComponent {
       // Hack to fix timeline jumps on second rendering when auto-collapsing
       this.setState({ autoCollapsed: true });
     }
+
+    this.didShowCard  = !this.props.muted && !this.props.hidden && this.props.status.get('card') && this.props.settings.get('inline_preview_cards');
   }
 
   getSnapshotBeforeUpdate (prevProps, prevState) {
@@ -228,8 +230,10 @@ export default class Status extends ImmutablePureComponent {
 
   //  Hack to fix timeline jumps on second rendering when auto-collapsing
   componentDidUpdate (prevProps, prevState, snapshot) {
-    if (this.state.autoCollapsed) {
-      this.setState({ autoCollapsed: false });
+    const doShowCard  = !this.props.muted && !this.props.hidden && this.props.status.get('card') && this.props.settings.get('inline_preview_cards');
+    if (this.state.autoCollapsed || (doShowCard && !this.didShowCard)) {
+      if (doShowCard) this.didShowCard = true;
+      if (this.state.autoCollapsed) this.setState({ autoCollapsed: false });
       if (snapshot !== null && this.props.updateScrollBottom) {
         if (this.node.offsetTop < snapshot.top) {
           this.props.updateScrollBottom(snapshot.height - snapshot.top);