forked from zulip/zulip-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
topics: Fix failure to load from offline state.
This fix first checks for the online status in TopicListScreen, and if found to be online, renders TopicList, which houses all the Redux logic and the call to Selectors that were originally in TopicListScreen. Fixes zulip#2310
- Loading branch information
1 parent
95676a3
commit e069bf1
Showing
3 changed files
with
33 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,29 @@ | ||
/* @flow */ | ||
import React, { PureComponent } from 'react'; | ||
|
||
import type { Actions, Stream, TopicDetails } from '../types'; | ||
import connectWithActions from '../connectWithActions'; | ||
import { Screen } from '../common'; | ||
import { topicNarrow } from '../utils/narrow'; | ||
import { getTopicsInScreen } from '../selectors'; | ||
import { getStreamEditInitialValues } from '../subscriptions/subscriptionSelectors'; | ||
import { LoadingIndicator, Screen } from '../common'; | ||
import { getSession } from '../selectors'; | ||
import TopicList from './TopicList'; | ||
|
||
type Props = { | ||
actions: Actions, | ||
stream: Stream, | ||
topics: TopicDetails[], | ||
isOnline: boolean, | ||
}; | ||
|
||
class TopicListScreen extends PureComponent<Props> { | ||
props: Props; | ||
|
||
componentDidMount() { | ||
const { actions, stream } = this.props; | ||
actions.fetchTopics(stream.stream_id); | ||
} | ||
|
||
handlePress = (streamObj: string, topic: string) => { | ||
const { actions, stream } = this.props; | ||
actions.doNarrow(topicNarrow(stream.name, topic)); | ||
}; | ||
|
||
render() { | ||
const { topics } = this.props; | ||
const { isOnline } = this.props; | ||
|
||
return ( | ||
<Screen title="Topics" padding> | ||
<TopicList topics={topics} onPress={this.handlePress} /> | ||
{isOnline ? <TopicList /> : <LoadingIndicator size={40} />} | ||
</Screen> | ||
); | ||
} | ||
} | ||
|
||
export default connectWithActions(state => ({ | ||
stream: getStreamEditInitialValues(state), | ||
topics: getTopicsInScreen(state), | ||
isOnline: getSession(state).isOnline, | ||
}))(TopicListScreen); |