summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2015-12-02 11:11:49 -0500
committerHarrison Healey <harrisonmhealey@gmail.com>2015-12-02 11:11:49 -0500
commitac3f0335be0f2f68e13871153e61c7c9dc632f17 (patch)
tree95dfd83a0505b43caf6b8e319be1c00c5d90f386
parent5e51de6f2c9a69a205abe9f8ebd26592809fb0d0 (diff)
parentd0578f73bf6540013a59f80d2fa0c0d878be6365 (diff)
downloadchat-ac3f0335be0f2f68e13871153e61c7c9dc632f17.tar.gz
chat-ac3f0335be0f2f68e13871153e61c7c9dc632f17.tar.bz2
chat-ac3f0335be0f2f68e13871153e61c7c9dc632f17.zip
Merge pull request #1578 from mattermost/emitter-leak
Fix emitter leak
-rw-r--r--web/react/components/posts_view.jsx10
1 files changed, 8 insertions, 2 deletions
diff --git a/web/react/components/posts_view.jsx b/web/react/components/posts_view.jsx
index dc23d6792..d0eee5a23 100644
--- a/web/react/components/posts_view.jsx
+++ b/web/react/components/posts_view.jsx
@@ -280,17 +280,23 @@ export default class PostsView extends React.Component {
this.updateScrolling();
}
window.addEventListener('resize', this.handleResize);
- PreferenceStore.addChangeListener(this.updateState);
}
componentWillUnmount() {
window.removeEventListener('resize', this.handleResize);
- PreferenceStore.removeChangeListener(this.updateState);
}
componentDidUpdate() {
if (this.props.postList != null) {
this.updateScrolling();
}
}
+ componentWillReceiveProps(nextProps) {
+ if (!this.props.isActive && nextProps.isActive) {
+ this.updateState();
+ PreferenceStore.addChangeListener(this.updateState);
+ } else if (this.props.isActive && !nextProps.isActive) {
+ PreferenceStore.removeChangeListener(this.updateState);
+ }
+ }
shouldComponentUpdate(nextProps, nextState) {
if (this.props.isActive !== nextProps.isActive) {
return true;