From 9c03fd9caef575792f08fd4e5c396d8d72bad09f Mon Sep 17 00:00:00 2001 From: unarist Date: Fri, 7 Jul 2017 04:26:21 +0900 Subject: [PATCH] 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. --- app/javascript/mastodon/components/status.js | 4 ++++ .../features/ui/util/intersection_observer_wrapper.js | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index a837659c2..ff574ab3d 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -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; } 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; } }