From 086dd832d3d2c8103e7d6f99d72d27bea97ce7b0 Mon Sep 17 00:00:00 2001 From: wakarimasen Date: Tue, 7 Mar 2017 17:27:12 +0100 Subject: Visual feedback on failure to fetch new statuses --- src/services/timeline_fetcher/timeline_fetcher.service.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/services/timeline_fetcher/timeline_fetcher.service.js') diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 37bbcd82..40f568c3 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -12,6 +12,15 @@ const update = ({store, statuses, timeline, showImmediately}) => { }) } +const setError = ({store, timeline, value}) => { + const ccTimeline = camelCase(timeline) + + store.dispatch('setError', { + timeline: ccTimeline, + value + }) +} + const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false}) => { const args = { timeline, credentials } const rootState = store.rootState || store.state @@ -25,6 +34,8 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false return apiService.fetchTimeline(args) .then((statuses) => update({store, statuses, timeline, showImmediately})) + .then(() => setError({store, timeline, value: false})) + .catch(() => setError({store, timeline, value: true})) } const startFetching = ({ timeline = 'friends', credentials, store }) => { -- cgit v1.2.3-70-g09d2 From 7d522583780cae5746112f204b3f8c604d5a87bd Mon Sep 17 00:00:00 2001 From: wakarimasen Date: Tue, 7 Mar 2017 21:38:55 +0100 Subject: Move rejection handler --- src/services/timeline_fetcher/timeline_fetcher.service.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/services/timeline_fetcher/timeline_fetcher.service.js') diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 40f568c3..e684a170 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -5,6 +5,8 @@ import apiService from '../api/api.service.js' const update = ({store, statuses, timeline, showImmediately}) => { const ccTimeline = camelCase(timeline) + setError({store, timeline, value: false}) + store.dispatch('addNewStatuses', { timeline: ccTimeline, statuses, @@ -33,9 +35,8 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false } return apiService.fetchTimeline(args) - .then((statuses) => update({store, statuses, timeline, showImmediately})) - .then(() => setError({store, timeline, value: false})) - .catch(() => setError({store, timeline, value: true})) + .then((statuses) => update({store, statuses, timeline, showImmediately}), + () => setError({store, timeline, value: true})) } const startFetching = ({ timeline = 'friends', credentials, store }) => { -- cgit v1.2.3-70-g09d2