diff options
| author | Wyatt Benno <wyattbenno@gmail.com> | 2019-12-09 10:31:57 +0900 |
|---|---|---|
| committer | Wyatt Benno <wyattbenno@gmail.com> | 2019-12-09 10:31:57 +0900 |
| commit | 8ee80339555c53d45602f40fdbe6b487a6992515 (patch) | |
| tree | 4f85e249bf9c57c97cc34ad899020a334ccbb718 | |
| parent | 1a043d4350c1cab2a56c5197ee8fb31e68593567 (diff) | |
Set error data
| -rw-r--r-- | src/components/timeline/timeline.vue | 4 | ||||
| -rw-r--r-- | src/i18n/en.json | 1 | ||||
| -rw-r--r-- | src/modules/statuses.js | 2 | ||||
| -rw-r--r-- | src/services/api/api.service.js | 7 | ||||
| -rw-r--r-- | src/services/timeline_fetcher/timeline_fetcher.service.js | 4 |
5 files changed, 11 insertions, 7 deletions
diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue index d9f4025d..bb4ab379 100644 --- a/src/components/timeline/timeline.vue +++ b/src/components/timeline/timeline.vue @@ -16,7 +16,7 @@ class="loadmore-error alert error" @click.prevent > - {{ $t('timeline.error_403') }} + {{ errorData.statusText }} </div> <button v-if="timeline.newStatusCount > 0 && !timelineError && !errorData" @@ -84,7 +84,7 @@ v-else-if="errorData" href="#" > - <div class="new-status-notification text-center panel-footer">{{ errorData }}</div> + <div class="new-status-notification text-center panel-footer">{{ errorData.error }}</div> </a> <div v-else diff --git a/src/i18n/en.json b/src/i18n/en.json index 1dd99062..85146ef5 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -535,7 +535,6 @@ "collapse": "Collapse", "conversation": "Conversation", "error_fetching": "Error fetching updates", - "error_403": "Access denied", "load_older": "Load older statuses", "no_retweet_hint": "Post is marked as followers-only or direct and cannot be repeated", "repeated": "repeated", diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 4068aa02..e3a1f293 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -38,7 +38,7 @@ export const defaultState = () => ({ notifications: emptyNotifications(), favorites: new Set(), error: false, - errorData: '', + errorData: null, timelines: { mentions: emptyTl(), public: emptyTl(), diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 45b63caf..63e72e30 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -529,9 +529,12 @@ const fetchTimeline = ({ const queryString = map(params, (param) => `${param[0]}=${param[1]}`).join('&') url += `?${queryString}` - + let status = '' + let statusText = '' return fetch(url, { headers: authHeaders(credentials) }) .then((data) => { + status = data.status + statusText = data.statusText return data }) .then((data) => data.json()) @@ -539,6 +542,8 @@ const fetchTimeline = ({ if (!data.error) { return data.map(isNotifications ? parseNotification : parseStatus) } else { + data.status = status + data.statusText = statusText return data } }) diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 68644261..c6b28ad5 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -6,7 +6,7 @@ const update = ({ store, statuses, timeline, showImmediately, userId }) => { const ccTimeline = camelCase(timeline) store.dispatch('setError', { value: false }) - store.dispatch('setErrorData', { value: false }) + store.dispatch('setErrorData', { value: null }) store.dispatch('addNewStatuses', { timeline: ccTimeline, @@ -47,7 +47,7 @@ const fetchAndUpdate = ({ return apiService.fetchTimeline(args) .then((statuses) => { if (statuses.error) { - store.dispatch('setErrorData', { value: statuses.error }) + store.dispatch('setErrorData', { value: statuses }) return } if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) { |
