diff --git a/app/soapbox/features/home_timeline/index.js b/app/soapbox/features/home_timeline/index.js index f65198187..51d96beb5 100644 --- a/app/soapbox/features/home_timeline/index.js +++ b/app/soapbox/features/home_timeline/index.js @@ -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 ( diff --git a/app/soapbox/reducers/timelines.js b/app/soapbox/reducers/timelines.js index 058a40b70..616152248 100644 --- a/app/soapbox/reducers/timelines.js +++ b/app/soapbox/reducers/timelines.js @@ -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: