Merge branch 'suggestions-home-fix' into 'develop'
Suggestions: don't show suggestions if Home timeline failed See merge request soapbox-pub/soapbox-fe!912
This commit is contained in:
commit
59a2b3dd96
2 changed files with 18 additions and 3 deletions
|
@ -27,6 +27,7 @@ const mapStateToProps = state => {
|
|||
isPartial: state.getIn(['timelines', 'home', 'isPartial']),
|
||||
siteTitle: state.getIn(['instance', 'title']),
|
||||
isLoading: state.getIn(['timelines', 'home', 'isLoading'], true),
|
||||
loadingFailed: state.getIn(['timelines', 'home', 'loadingFailed'], false),
|
||||
isEmpty: state.getIn(['timelines', 'home', 'items'], ImmutableOrderedSet()).isEmpty(),
|
||||
features,
|
||||
};
|
||||
|
@ -43,6 +44,7 @@ class HomeTimeline extends React.PureComponent {
|
|||
isPartial: PropTypes.bool,
|
||||
siteTitle: PropTypes.string,
|
||||
isLoading: PropTypes.bool,
|
||||
loadingFailed: PropTypes.bool,
|
||||
isEmpty: PropTypes.bool,
|
||||
features: PropTypes.object.isRequired,
|
||||
};
|
||||
|
@ -99,9 +101,9 @@ class HomeTimeline extends React.PureComponent {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { intl, siteTitle, isLoading, isEmpty, features } = this.props;
|
||||
const { intl, siteTitle, isLoading, loadingFailed, isEmpty, features } = this.props;
|
||||
const { done } = this.state;
|
||||
const showSuggestions = features.suggestions && isEmpty && !isLoading && !done;
|
||||
const showSuggestions = features.suggestions && isEmpty && !isLoading && !loadingFailed && !done;
|
||||
|
||||
return (
|
||||
<Column label={intl.formatMessage(messages.title)} transparent={!showSuggestions}>
|
||||
|
|
|
@ -68,11 +68,17 @@ const setLoading = (state, timelineId, loading) => {
|
|||
return state.update(timelineId, initialTimeline, timeline => timeline.set('isLoading', loading));
|
||||
};
|
||||
|
||||
// Keep track of when a timeline failed to load
|
||||
const setFailed = (state, timelineId, failed) => {
|
||||
return state.update(timelineId, initialTimeline, timeline => timeline.set('loadingFailed', failed));
|
||||
};
|
||||
|
||||
const expandNormalizedTimeline = (state, timelineId, statuses, next, isPartial, isLoadingRecent) => {
|
||||
const newIds = getStatusIds(statuses);
|
||||
|
||||
return state.update(timelineId, initialTimeline, timeline => timeline.withMutations(timeline => {
|
||||
timeline.set('isLoading', false);
|
||||
timeline.set('loadingFailed', false);
|
||||
timeline.set('isPartial', isPartial);
|
||||
|
||||
if (!next && !isLoadingRecent) timeline.set('hasMore', false);
|
||||
|
@ -284,6 +290,13 @@ const importStatus = (state, status, idempotencyKey) => {
|
|||
});
|
||||
};
|
||||
|
||||
const handleExpandFail = (state, timelineId) => {
|
||||
return state.withMutations(state => {
|
||||
setLoading(state, timelineId, false);
|
||||
setFailed(state, timelineId, true);
|
||||
});
|
||||
};
|
||||
|
||||
export default function timelines(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case STATUS_CREATE_REQUEST:
|
||||
|
@ -293,7 +306,7 @@ export default function timelines(state = initialState, action) {
|
|||
case TIMELINE_EXPAND_REQUEST:
|
||||
return setLoading(state, action.timeline, true);
|
||||
case TIMELINE_EXPAND_FAIL:
|
||||
return setLoading(state, action.timeline, false);
|
||||
return handleExpandFail(state, action.timeline);
|
||||
case TIMELINE_EXPAND_SUCCESS:
|
||||
return expandNormalizedTimeline(state, action.timeline, fromJS(action.statuses), action.next, action.partial, action.isLoadingRecent);
|
||||
case TIMELINE_UPDATE:
|
||||
|
|
Loading…
Reference in a new issue