diff options
author | nickago <ngonella@calpoly.edu> | 2015-07-13 08:34:34 -0700 |
---|---|---|
committer | nickago <ngonella@calpoly.edu> | 2015-07-13 08:34:34 -0700 |
commit | 614992dcb7b4a4cdcedefe3ca813a03b758a97f0 (patch) | |
tree | 7cb940e47842d47aa08c68949a10d19d5a67cf58 /web/react/components/post_right.jsx | |
parent | b63d42c2c6256ab5e904939a83d7e3eb530e101e (diff) | |
download | chat-614992dcb7b4a4cdcedefe3ca813a03b758a97f0.tar.gz chat-614992dcb7b4a4cdcedefe3ca813a03b758a97f0.tar.bz2 chat-614992dcb7b4a4cdcedefe3ca813a03b758a97f0.zip |
Added timestamp updates to right side and cleaned code
Diffstat (limited to 'web/react/components/post_right.jsx')
-rw-r--r-- | web/react/components/post_right.jsx | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/web/react/components/post_right.jsx b/web/react/components/post_right.jsx index 115ee87d4..89a616d27 100644 --- a/web/react/components/post_right.jsx +++ b/web/react/components/post_right.jsx @@ -279,9 +279,11 @@ function getStateFromStores() { } module.exports = React.createClass({ + wasForced: false, componentDidMount: function() { PostStore.addSelectedPostChangeListener(this._onChange); PostStore.addChangeListener(this._onChangeAll); + UserStore.addStatusesChangeListener(this._onTimeChange); this.resize(); var self = this; $(window).resize(function(){ @@ -289,11 +291,15 @@ module.exports = React.createClass({ }); }, componentDidUpdate: function() { - this.resize(); + if(!this.wasForced){ + this.resize(); + wasForced = false + } }, componentWillUnmount: function() { PostStore.removeSelectedPostChangeListener(this._onChange); PostStore.removeChangeListener(this._onChangeAll); + UserStore.removeStatusesChangeListener(this._onTimeChange) }, _onChange: function() { if (this.isMounted()) { @@ -333,6 +339,14 @@ module.exports = React.createClass({ this.setState(getStateFromStores()); } }, + _onTimeChange: function() { + this.wasForced = true; + for (var key in this.refs) { + if(this.refs[key].forceUpdate != undefined) { + this.refs[key].forceUpdate(); + } + } + }, getInitialState: function() { return getStateFromStores(); }, @@ -392,7 +406,7 @@ module.exports = React.createClass({ <RootPost post={root_post} commentCount={posts_array.length}/> <div className="post-right-comments-container"> { posts_array.map(function(cpost) { - return <CommentPost key={cpost.id} post={cpost} selected={ (cpost.id == selected_post.id) } /> + return <CommentPost ref={cpost.id} key={cpost.id} post={cpost} selected={ (cpost.id == selected_post.id) } /> })} </div> <div className="post-create__container"> |