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
This commit is contained in:
parent
f50b2b9412
commit
4605ecc359
2 changed files with 16 additions and 12 deletions
|
|
@ -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 (
|
||||
<View style={style.container}>
|
||||
<Loading/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={style.container}>
|
||||
<View style={style.profilesContainer}>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue