logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe
commit: 9c03fd9caef575792f08fd4e5c396d8d72bad09f
parent: 34c8a46d7de2b7e0b495b5c4a51c95c6a6b047b7
Author: unarist <m.unarist@gmail.com>
Date:   Fri,  7 Jul 2017 04:26:21 +0900

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:

Mapp/javascript/mastodon/components/status.js4++++
Mapp/javascript/mastodon/features/ui/util/intersection_observer_wrapper.js9+++++++++
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git 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 @@ -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; } }