diff options
author | =Corey Hulen <corey@hulen.com> | 2016-03-14 10:23:51 -0700 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2016-03-14 10:23:51 -0700 |
commit | ea3f25924ea64a2dd1e73624c0d30824e1efb240 (patch) | |
tree | a4a2b2bdc37bd675fb89837713995ad44a27427b /web/react/components/post_focus_view.jsx | |
parent | 397ebec88c2db3569efd77238bf877e976492d34 (diff) | |
parent | bf7ae0711743926cfbb031675cc3320d7a942465 (diff) | |
download | chat-ea3f25924ea64a2dd1e73624c0d30824e1efb240.tar.gz chat-ea3f25924ea64a2dd1e73624c0d30824e1efb240.tar.bz2 chat-ea3f25924ea64a2dd1e73624c0d30824e1efb240.zip |
Merge branch 'master' into PLT-2115
Diffstat (limited to 'web/react/components/post_focus_view.jsx')
-rw-r--r-- | web/react/components/post_focus_view.jsx | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/web/react/components/post_focus_view.jsx b/web/react/components/post_focus_view.jsx index 44a0bae09..fd654f502 100644 --- a/web/react/components/post_focus_view.jsx +++ b/web/react/components/post_focus_view.jsx @@ -5,7 +5,8 @@ import PostsView from './posts_view.jsx'; import PostStore from '../stores/post_store.jsx'; import ChannelStore from '../stores/channel_store.jsx'; -import * as EventHelpers from '../dispatcher/event_helpers.jsx'; +import UserStore from '../stores/user_store.jsx'; +import * as GlobalActions from '../action_creators/global_actions.jsx'; import {FormattedMessage} from 'mm-intl'; @@ -15,6 +16,7 @@ export default class PostFocusView extends React.Component { this.onChannelChange = this.onChannelChange.bind(this); this.onPostsChange = this.onPostsChange.bind(this); + this.onUserChange = this.onUserChange.bind(this); this.handlePostsViewScroll = this.handlePostsViewScroll.bind(this); this.loadMorePostsTop = this.loadMorePostsTop.bind(this); this.loadMorePostsBottom = this.loadMorePostsBottom.bind(this); @@ -26,18 +28,21 @@ export default class PostFocusView extends React.Component { scrollPostId: focusedPostId, postList: PostStore.getVisiblePosts(focusedPostId), atTop: PostStore.getVisibilityAtTop(focusedPostId), - atBottom: PostStore.getVisibilityAtBottom(focusedPostId) + atBottom: PostStore.getVisibilityAtBottom(focusedPostId), + currentUser: UserStore.getCurrentUser() }; } componentDidMount() { ChannelStore.addChangeListener(this.onChannelChange); PostStore.addChangeListener(this.onPostsChange); + UserStore.addChangeListener(this.onUserChange); } componentWillUnmount() { ChannelStore.removeChangeListener(this.onChannelChange); PostStore.removeChangeListener(this.onPostsChange); + UserStore.removeChangeListener(this.onUserChange); } onChannelChange() { @@ -46,6 +51,10 @@ export default class PostFocusView extends React.Component { }); } + onUserChange() { + this.setState({currentUser: UserStore.getCurrentUser()}); + } + onPostsChange() { const focusedPostId = PostStore.getFocusedPostId(); if (focusedPostId == null) { @@ -65,11 +74,11 @@ export default class PostFocusView extends React.Component { } loadMorePostsTop() { - EventHelpers.emitLoadMorePostsFocusedTopEvent(); + GlobalActions.emitLoadMorePostsFocusedTopEvent(); } loadMorePostsBottom() { - EventHelpers.emitLoadMorePostsFocusedBottomEvent(); + GlobalActions.emitLoadMorePostsFocusedBottomEvent(); } getIntroMessage() { @@ -89,6 +98,10 @@ export default class PostFocusView extends React.Component { const postsToHighlight = {}; postsToHighlight[this.state.scrollPostId] = true; + if (!this.state.currentUser || !this.state.postList) { + return null; + } + return ( <div id='post-list'> <PostsView @@ -106,6 +119,7 @@ export default class PostFocusView extends React.Component { messageSeparatorTime={0} postsToHighlight={postsToHighlight} profiles={this.props.profiles} + currentUser={this.state.currentUser} /> </div> ); |