From 4605ecc359475e149fd4f8dae5957824a6e37406 Mon Sep 17 00:00:00 2001 From: enahum Date: Wed, 11 Oct 2017 16:36:40 -0300 Subject: [PATCH] Do not show channel intro while posts are being loaded (#1012) * Do not show channel intro while posts are being loaded * check if we have posts in the channel --- app/components/channel_intro/channel_intro.js | 13 +++++++++++-- app/components/channel_intro/index.js | 15 +++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/components/channel_intro/channel_intro.js b/app/components/channel_intro/channel_intro.js index 5c79d5f71..ff20b6796 100644 --- a/app/components/channel_intro/channel_intro.js +++ b/app/components/channel_intro/channel_intro.js @@ -12,6 +12,7 @@ import {getFullName} from 'mattermost-redux/utils/user_utils'; import {General} from 'mattermost-redux/constants'; import {injectIntl, intlShape} from 'react-intl'; +import Loading from 'app/components/loading'; import ProfilePicture from 'app/components/profile_picture'; import {preventDoubleTap} from 'app/utils/tap'; import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme'; @@ -22,6 +23,7 @@ class ChannelIntro extends PureComponent { currentChannel: PropTypes.object.isRequired, currentChannelMembers: PropTypes.array.isRequired, intl: intlShape.isRequired, + isLoadingPosts: PropTypes.bool, navigator: PropTypes.object.isRequired, theme: PropTypes.object.isRequired }; @@ -304,10 +306,17 @@ class ChannelIntro extends PureComponent { }; render() { - const {theme} = this.props; - + const {isLoadingPosts, theme} = this.props; const style = getStyleSheet(theme); + if (isLoadingPosts) { + return ( + + + + ); + } + return ( diff --git a/app/components/channel_intro/index.js b/app/components/channel_intro/index.js index a58a523de..8763f74f3 100644 --- a/app/components/channel_intro/index.js +++ b/app/components/channel_intro/index.js @@ -1,9 +1,8 @@ // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import {General} from 'mattermost-redux/constants'; +import {General, RequestStatus} from 'mattermost-redux/constants'; import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentUser, getProfilesInCurrentChannel} from 'mattermost-redux/selectors/entities/users'; @@ -14,6 +13,7 @@ import ChannelIntro from './channel_intro'; function mapStateToProps(state) { const currentChannel = getCurrentChannel(state) || {}; const currentUser = getCurrentUser(state) || {}; + const {status: getPostsRequestStatus} = state.requests.posts.getPosts; let currentChannelMembers = []; if (currentChannel.type === General.DM_CHANNEL) { @@ -28,20 +28,15 @@ function mapStateToProps(state) { } const creator = currentChannel.creator_id === currentUser.id ? currentUser : state.entities.users.profiles[currentChannel.creator_id]; + const postsInChannel = state.entities.posts.postsInChannel[currentChannel.id] || []; return { creator, currentChannel, currentChannelMembers, + isLoadingPosts: !postsInChannel.length && getPostsRequestStatus === RequestStatus.STARTED, theme: getTheme(state) }; } -function mapDispatchToProps(dispatch) { - // placeholder for invite and set header actions - return { - actions: bindActionCreators({}, dispatch) - }; -} - -export default connect(mapStateToProps, mapDispatchToProps)(ChannelIntro); +export default connect(mapStateToProps)(ChannelIntro);