]> cat aescling's git repositories - mastodon.git/commitdiff
Unobserve status on unmount (#4013)
authorunarist <m.unarist@gmail.com>
Thu, 6 Jul 2017 19:26:21 +0000 (04:26 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 6 Jul 2017 19:26:21 +0000 (21:26 +0200)
This fixes a warning on status unmounting (e.g. deletion).

This also resets IntersectionObserverWrapper on disconnect to avoid `unobserve()` calls
which has bug in Edge.

app/javascript/mastodon/components/status.js
app/javascript/mastodon/features/ui/util/intersection_observer_wrapper.js

index a837659c2cd5bcf252dcedbbd99166e6021d7dff..ff574ab3d3bd3c43fb6ed90f200af3c3c634d65f 100644 (file)
@@ -90,6 +90,10 @@ export default class Status extends ImmutablePureComponent {
   }
 
   componentWillUnmount () {
+    if (this.props.intersectionObserverWrapper) {
+      this.props.intersectionObserverWrapper.unobserve(this.props.id, this.node);
+    }
+
     this.componentMounted = false;
   }
 
index 0e959f9ae8e9f4955d090c38ce8e3ef2f9c6c41d..2b24c65831d87c27d71ed184dd7899d5772fb89e 100644 (file)
@@ -37,9 +37,18 @@ class IntersectionObserverWrapper {
     }
   }
 
+  unobserve (id, node) {
+    if (this.observer) {
+      delete this.callbacks[id];
+      this.observer.unobserve(node);
+    }
+  }
+
   disconnect () {
     if (this.observer) {
+      this.callbacks = {};
       this.observer.disconnect();
+      this.observer = null;
     }
   }