From 58efa5863bd16777ae6f2c65054ed81ea30792b8 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 8 Nov 2017 13:55:11 -0500 Subject: [PATCH] RN-435 Fixed Loading messages... message not appearing (#1104) * RN-435 Fixed Loading Messages... message not appearing * Made capitalization of Loading messages... more consistent * Fixed ignored eslint warning * Removed outdated FIXME comment * Removed unnecessary view --- .../post_list/load_more_posts/index.js | 14 +++++++++++++ .../{ => load_more_posts}/load_more_posts.js | 16 +++++--------- app/components/post_list/post_list.js | 21 +++++++++---------- assets/base/i18n/en.json | 2 +- 4 files changed, 30 insertions(+), 23 deletions(-) create mode 100644 app/components/post_list/load_more_posts/index.js rename app/components/post_list/{ => load_more_posts}/load_more_posts.js (84%) diff --git a/app/components/post_list/load_more_posts/index.js b/app/components/post_list/load_more_posts/index.js new file mode 100644 index 000000000..5d0c37dd6 --- /dev/null +++ b/app/components/post_list/load_more_posts/index.js @@ -0,0 +1,14 @@ +// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import {connect} from 'react-redux'; + +import LoadMorePosts from './load_more_posts'; + +function mapStateToProps(state, ownProps) { + return { + loading: Boolean(state.views.channel.loadingPosts[ownProps.channelId]) + }; +} + +export default connect(mapStateToProps)(LoadMorePosts); diff --git a/app/components/post_list/load_more_posts.js b/app/components/post_list/load_more_posts/load_more_posts.js similarity index 84% rename from app/components/post_list/load_more_posts.js rename to app/components/post_list/load_more_posts/load_more_posts.js index 693904d60..47b669c0b 100644 --- a/app/components/post_list/load_more_posts.js +++ b/app/components/post_list/load_more_posts/load_more_posts.js @@ -2,7 +2,6 @@ // See License.txt for license information. import React, {PureComponent} from 'react'; -import {connect} from 'react-redux'; import PropTypes from 'prop-types'; import { TouchableOpacity, @@ -14,8 +13,9 @@ import {makeStyleSheetFromTheme} from 'app/utils/theme'; import FormattedText from 'app/components/formatted_text'; -class LoadMorePosts extends PureComponent { +export default class LoadMorePosts extends PureComponent { static propTypes = { + channelId: PropTypes.string.isRequired, // eslint-disable-line react/no-unused-prop-types loading: PropTypes.bool.isRequired, loadMore: PropTypes.func, theme: PropTypes.object.isRequired, @@ -32,10 +32,12 @@ class LoadMorePosts extends PureComponent { renderText(style) { let i18nId = 'posts_view.loadMore'; let defaultMessage = 'Load more messages'; + if (this.props.loading) { i18nId = 'mobile.loading_posts'; - defaultMessage = 'Loading Messages...'; + defaultMessage = 'Loading messages...'; } + return ( { } }; }); - -function mapStateToProps(state, ownProps) { - return { - loading: state.views.channel.loadingPosts[ownProps.channelId] || false - }; -} - -export default connect(mapStateToProps)(LoadMorePosts); diff --git a/app/components/post_list/post_list.js b/app/components/post_list/post_list.js index c48a94f4b..dc21bfb5e 100644 --- a/app/components/post_list/post_list.js +++ b/app/components/post_list/post_list.js @@ -3,10 +3,7 @@ import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; -import { - StyleSheet, - View -} from 'react-native'; +import {StyleSheet} from 'react-native'; import ChannelIntro from 'app/components/channel_intro'; import FlatList from 'app/components/inverted_flat_list'; @@ -162,18 +159,20 @@ export default class PostList extends PureComponent { }; renderFooter = () => { + if (!this.props.channelId) { + return null; + } + if (this.props.showLoadMore) { - return ; - } else if (this.props.channelId) { - // FIXME: Only show the channel intro when we are at the very start of the channel return ( - - - + ); } - return null; + return ; }; render() { diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json index 1dadee284..4187faa9d 100644 --- a/assets/base/i18n/en.json +++ b/assets/base/i18n/en.json @@ -1966,7 +1966,7 @@ "mobile.join_channel.error": "We couldn't join the channel {displayName}. Please check your connection and try again.", "mobile.loading_channels": "Loading Channels...", "mobile.loading_members": "Loading Members...", - "mobile.loading_posts": "Loading Messages...", + "mobile.loading_posts": "Loading messages...", "mobile.login_options.choose_title": "Choose your login method", "mobile.managed.blocked_by": "Blocked by {vendor}", "mobile.managed.exit": "Exit",