Browse Source

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.
pull/4/head
unarist 6 years ago
committed by Eugen Rochko
parent
commit
9c03fd9cae
2 changed files with 13 additions and 0 deletions
  1. +4
    -0
      app/javascript/mastodon/components/status.js
  2. +9
    -0
      app/javascript/mastodon/features/ui/util/intersection_observer_wrapper.js

+ 4
- 0
app/javascript/mastodon/components/status.js View 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;
}

+ 9
- 0
app/javascript/mastodon/features/ui/util/intersection_observer_wrapper.js View 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;
}
}

Loading…
Cancel
Save