about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/ui/util
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2017-07-07 04:26:21 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-07-06 21:26:21 +0200
commit9c03fd9caef575792f08fd4e5c396d8d72bad09f (patch)
treebc9d921feb5770281c3e045a834eebfafd7af2e7 /app/javascript/mastodon/features/ui/util
parent34c8a46d7de2b7e0b495b5c4a51c95c6a6b047b7 (diff)
Unobserve status on unmount (#4013)
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.
Diffstat (limited to 'app/javascript/mastodon/features/ui/util')
-rw-r--r--app/javascript/mastodon/features/ui/util/intersection_observer_wrapper.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/ui/util/intersection_observer_wrapper.js b/app/javascript/mastodon/features/ui/util/intersection_observer_wrapper.js
index 0e959f9ae..2b24c6583 100644
--- a/app/javascript/mastodon/features/ui/util/intersection_observer_wrapper.js
+++ b/app/javascript/mastodon/features/ui/util/intersection_observer_wrapper.js
@@ -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;
     }
   }