diff options
author | Joram Wilander <jwawilander@gmail.com> | 2015-07-14 10:55:37 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2015-07-14 10:55:37 -0400 |
commit | 1f1ad8234aa44268ce76d24b80c86f5b009cc5e6 (patch) | |
tree | 259676a46d61a7ed7eaca7aedb1fa0865c0d7dc6 /web/react | |
parent | 2e4b61ef3847a63ed14b02a5466add33de8c8cf9 (diff) | |
parent | 634df1c6242772e44fed5f64ac238adf2d0503a0 (diff) | |
download | chat-1f1ad8234aa44268ce76d24b80c86f5b009cc5e6.tar.gz chat-1f1ad8234aa44268ce76d24b80c86f5b009cc5e6.tar.bz2 chat-1f1ad8234aa44268ce76d24b80c86f5b009cc5e6.zip |
Merge pull request #174 from nickago/MM-831-3
MM-831 Time change ping riding on the status interupt for timestamp update
Diffstat (limited to 'web/react')
-rw-r--r-- | web/react/components/post_list.jsx | 16 | ||||
-rw-r--r-- | web/react/components/post_right.jsx | 18 |
2 files changed, 31 insertions, 3 deletions
diff --git a/web/react/components/post_list.jsx b/web/react/components/post_list.jsx index 9349d0240..e73bc10cc 100644 --- a/web/react/components/post_list.jsx +++ b/web/react/components/post_list.jsx @@ -35,6 +35,8 @@ module.exports = React.createClass({ oldScrollHeight: 0, oldZoom: 0, scrolledToNew: false, + preForcePosision: 0, + wasForced: false, componentDidMount: function() { var user = UserStore.getCurrentUser(); if (user.props && user.props.theme) { @@ -50,6 +52,7 @@ module.exports = React.createClass({ PostStore.addChangeListener(this._onChange); ChannelStore.addChangeListener(this._onChange); + UserStore.addStatusesChangeListener(this._onTimeChange); SocketStore.addChangeListener(this._onSocketChange); $(".post-list-holder-by-time").perfectScrollbar(); @@ -79,6 +82,11 @@ module.exports = React.createClass({ }); $(post_holder).scroll(function(e){ + if (self.wasForced) { + $(post_holder).scrollTop(self.preForcePosision); + $(post_holder).perfectScrollbar('update'); + self.wasForced = false; + } if (!self.preventScrollTrigger) { self.scrollPosition = $(post_holder).scrollTop() + $(post_holder).innerHeight(); } @@ -129,6 +137,7 @@ module.exports = React.createClass({ componentWillUnmount: function() { PostStore.removeChangeListener(this._onChange); ChannelStore.removeChangeListener(this._onChange); + UserStore.removeStatusesChangeListener(this._onTimeChange); SocketStore.removeChangeListener(this._onSocketChange); $('body').off('click.userpopover'); }, @@ -161,7 +170,7 @@ module.exports = React.createClass({ this.scrolledToNew = false; } this.setState(newState); - } + } }, _onSocketChange: function(msg) { if (msg.action == "posted") { @@ -225,6 +234,11 @@ module.exports = React.createClass({ AsyncClient.getProfiles(); } }, + _onTimeChange: function() { + this.wasForced = true; + this.preForcePosision = $(".post-list-holder-by-time").scrollTop(); + this.forceUpdate(); + }, getMorePosts: function(e) { e.preventDefault(); diff --git a/web/react/components/post_right.jsx b/web/react/components/post_right.jsx index 408fbf83a..27195dfba 100644 --- a/web/react/components/post_right.jsx +++ b/web/react/components/post_right.jsx @@ -281,9 +281,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(){ @@ -291,11 +293,15 @@ module.exports = React.createClass({ }); }, componentDidUpdate: function() { - this.resize(); + if(!this.wasForced){ + this.resize(); + this.wasForced = false; + } }, componentWillUnmount: function() { PostStore.removeSelectedPostChangeListener(this._onChange); PostStore.removeChangeListener(this._onChangeAll); + UserStore.removeStatusesChangeListener(this._onTimeChange); }, _onChange: function() { if (this.isMounted()) { @@ -335,6 +341,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(); }, @@ -394,7 +408,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"> |