Skip to content

Commit

Permalink
unread cards: Remove redundant loading indicator on session.loading.
Browse files Browse the repository at this point in the history
The loading indicator on an empty unread messages list during
`session.loading` is redundant, following the introduction of
LoadingBanner in this series of commits. Now, we can display the "No
unread messages" text as our best guess at the current state, even
though we know it's stale, since we're also displaying a loading
indicator above.

Fixes: #3387
Fixes: #3025
Fixes: #2725
  • Loading branch information
Chris Bobbe committed Feb 26, 2020
1 parent 3956804 commit ffafbba
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/unread/UnreadCards.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { SectionList } from 'react-native';

import type { Dispatch, PmConversationData, UnreadStreamItem, UserOrBot } from '../types';
import { connect } from '../react-redux';
import { LoadingIndicator, SearchEmptyState } from '../common';
import { SearchEmptyState } from '../common';
import PmConversationList from '../pm-conversations/PmConversationList';
import StreamItem from '../streams/StreamItem';
import TopicItem from '../streams/TopicItem';
import { streamNarrow, topicNarrow } from '../utils/narrow';
import {
getLoading,
getUnreadConversations,
getAllUsersByEmail,
getUnreadStreamsAndTopicsSansMuted,
Expand All @@ -21,7 +20,6 @@ import { doNarrow } from '../actions';
type Props = $ReadOnly<{|
conversations: PmConversationData[],
dispatch: Dispatch,
isLoading: boolean,
usersByEmail: Map<string, UserOrBot>,
unreadStreamsAndTopics: UnreadStreamItem[],
|}>;
Expand All @@ -36,7 +34,7 @@ class UnreadCards extends PureComponent<Props> {
};

render() {
const { isLoading, conversations, unreadStreamsAndTopics, ...restProps } = this.props;
const { conversations, unreadStreamsAndTopics, ...restProps } = this.props;
type Card =
| UnreadStreamItem
| { key: 'private', data: Array<$PropertyType<PmConversationList, 'props'>> };
Expand All @@ -49,11 +47,7 @@ class UnreadCards extends PureComponent<Props> {
];

if (unreadStreamsAndTopics.length === 0 && conversations.length === 0) {
return isLoading ? (
<LoadingIndicator size={40} />
) : (
<SearchEmptyState text="No unread messages" />
);
return <SearchEmptyState text="No unread messages" />;
}

return (
Expand Down Expand Up @@ -96,7 +90,6 @@ class UnreadCards extends PureComponent<Props> {
}

export default connect(state => ({
isLoading: getLoading(state),
conversations: getUnreadConversations(state),
usersByEmail: getAllUsersByEmail(state),
unreadStreamsAndTopics: getUnreadStreamsAndTopicsSansMuted(state),
Expand Down

0 comments on commit ffafbba

Please sign in to comment.