diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-10-30 14:29:15 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-11-02 08:16:57 -0500 |
commit | b9a3ff74dd2b299ae4980922a6dcc55002662517 (patch) | |
tree | 882abf9d49107d604f7c94e5739d63c84d742315 /web/react/components/post_list_container.jsx | |
parent | ed68f2e9015f3ac94ef1d5f7bf2941611625c60d (diff) | |
download | chat-b9a3ff74dd2b299ae4980922a6dcc55002662517.tar.gz chat-b9a3ff74dd2b299ae4980922a6dcc55002662517.tar.bz2 chat-b9a3ff74dd2b299ae4980922a6dcc55002662517.zip |
Hooking up external components
Diffstat (limited to 'web/react/components/post_list_container.jsx')
-rw-r--r-- | web/react/components/post_list_container.jsx | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/web/react/components/post_list_container.jsx b/web/react/components/post_list_container.jsx index 5e12f0e2b..90468ab66 100644 --- a/web/react/components/post_list_container.jsx +++ b/web/react/components/post_list_container.jsx @@ -25,10 +25,12 @@ export default class PostListContainer extends React.Component { this.loadMorePostsTop = this.loadMorePostsTop.bind(this); this.postsLoaded = this.postsLoaded.bind(this); this.postsLoadedFailure = this.postsLoadedFailure.bind(this); + this.handlePostListJumpRequest = this.handlePostListJumpRequest.bind(this); const currentChannelId = ChannelStore.getCurrentId(); const state = { scrollType: PostsView.SCROLL_TYPE_BOTTOM, + scrollPost: null, numPostsToDisplay: Constants.POST_CHUNK_SIZE }; if (currentChannelId) { @@ -51,11 +53,29 @@ export default class PostListContainer extends React.Component { ChannelStore.addChangeListener(this.onChannelChange); ChannelStore.addLeaveListener(this.onChannelLeave); PostStore.addChangeListener(this.onPostsChange); + PostStore.addPostListJumpListener(this.handlePostListJumpRequest); } componentWillUnmount() { ChannelStore.removeChangeListener(this.onChannelChange); ChannelStore.removeLeaveListener(this.onChannelLeave); PostStore.removeChangeListener(this.onPostsChange); + PostStore.removePostListJumpListener(this.handlePostListJumpRequest); + } + handlePostListJumpRequest(type, post) { + switch (type) { + case Constants.PostListJumpTypes.BOTTOM: + this.setState({scrollType: PostsView.SCROLL_TYPE_BOTTOM}); + break; + case Constants.PostListJumpTypes.POST: + this.setState({ + scrollType: PostsView.SCROLL_TYPE_POST, + scrollPost: post + }); + break; + case Constants.PostListJumpTypes.SIDEBAR_OPEN: + this.setState({scrollType: PostsView.SIDEBAR_OPEN}); + break; + } } onChannelChange() { const postLists = Object.assign({}, this.state.postLists); @@ -70,7 +90,7 @@ export default class PostListContainer extends React.Component { PostStore.clearUnseenDeletedPosts(channelId); let lastViewed = Number.MAX_VALUE; - let member = ChannelStore.getMember(channelId); + const member = ChannelStore.getMember(channelId); if (member != null) { lastViewed = member.last_viewed_at; } @@ -219,10 +239,11 @@ export default class PostListContainer extends React.Component { isActive={isActive} postList={postLists[i]} scrollType={this.state.scrollType} + scrollPost={this.state.scrollPost} postListScrolled={this.handlePostListScroll} loadMorePostsTopClicked={this.loadMorePostsTop} numPostsToDisplay={this.state.numPostsToDisplay} - introText={channel ? createChannelIntroMessage(channel) : []} + introText={channel ? createChannelIntroMessage(channel) : null} messageSeparatorTime={this.state.currentLastViewed} /> ); |