diff options
author | nickago <ngonella@calpoly.edu> | 2015-07-09 14:11:38 -0700 |
---|---|---|
committer | nickago <ngonella@calpoly.edu> | 2015-07-09 14:12:37 -0700 |
commit | 702112dfb315462919d276a72be2936ad45d7ceb (patch) | |
tree | 3bd70c9f82134fc9b1474b24f16ddd1be64c73c6 /web/react | |
parent | 04b80b6a25cddce0a44da1409ddc430bc8e797f5 (diff) | |
download | chat-702112dfb315462919d276a72be2936ad45d7ceb.tar.gz chat-702112dfb315462919d276a72be2936ad45d7ceb.tar.bz2 chat-702112dfb315462919d276a72be2936ad45d7ceb.zip |
Placed event listeners on higher level components to avoid app dispatcher vomit
Diffstat (limited to 'web/react')
-rw-r--r-- | web/react/components/post_info.jsx | 9 | ||||
-rw-r--r-- | web/react/components/post_list.jsx | 4 | ||||
-rw-r--r-- | web/react/components/sidebar_right.jsx | 5 |
3 files changed, 9 insertions, 9 deletions
diff --git a/web/react/components/post_info.jsx b/web/react/components/post_info.jsx index e06baee87..cf01747f0 100644 --- a/web/react/components/post_info.jsx +++ b/web/react/components/post_info.jsx @@ -5,15 +5,6 @@ var UserStore = require('../stores/user_store.jsx'); var utils = require('../utils/utils.jsx'); module.exports = React.createClass({ - componentDidMount: function() { - UserStore.addStatusesChangeListener(this._onChange); - }, - componentWillUnmount: function() { - UserStore.removeStatusesChangeListener(this._onChange); - }, - _onChange: function() { - this.forceUpdate(); - }, getInitialState: function() { return { }; }, diff --git a/web/react/components/post_list.jsx b/web/react/components/post_list.jsx index d6dc9ce30..2cccdff22 100644 --- a/web/react/components/post_list.jsx +++ b/web/react/components/post_list.jsx @@ -78,6 +78,7 @@ module.exports = React.createClass({ PostStore.addChangeListener(this._onChange); ChannelStore.addChangeListener(this._onChange); + UserStore.addStatusesChangeListener(this._onChange); SocketStore.addChangeListener(this._onSocketChange); $(".post-list-holder-by-time").perfectScrollbar(); @@ -157,6 +158,7 @@ module.exports = React.createClass({ componentWillUnmount: function() { PostStore.removeChangeListener(this._onChange); ChannelStore.removeChangeListener(this._onChange); + UserStore.removeStatusesChangeListener(this._onChange); SocketStore.removeChangeListener(this._onSocketChange); $('body').off('click.userpopover'); }, @@ -193,6 +195,8 @@ module.exports = React.createClass({ this.scrolledToNew = false; } this.setState(newState); + } else { + this.forceUpdate() } }, _onSocketChange: function(msg) { diff --git a/web/react/components/sidebar_right.jsx b/web/react/components/sidebar_right.jsx index 8334b345b..baffa0ab7 100644 --- a/web/react/components/sidebar_right.jsx +++ b/web/react/components/sidebar_right.jsx @@ -16,10 +16,15 @@ module.exports = React.createClass({ componentDidMount: function() { PostStore.addSearchChangeListener(this._onSearchChange); PostStore.addSelectedPostChangeListener(this._onSelectedChange); + UserStore.addStatusesChangeListener(this._onChange); }, componentWillUnmount: function() { PostStore.removeSearchChangeListener(this._onSearchChange); PostStore.removeSelectedPostChangeListener(this._onSelectedChange); + UserStore.removeStatusesChangeListener(this._onChange); + }, + _onChange: function() { + this.forceUpdate(); }, _onSelectedChange: function(from_search) { if (this.isMounted()) { |