Set error data

This commit is contained in:
Wyatt Benno 2019-12-09 10:31:57 +09:00
parent 1a043d4350
commit 8ee8033955
5 changed files with 11 additions and 7 deletions

View File

@ -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

View File

@ -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",

View File

@ -38,7 +38,7 @@ export const defaultState = () => ({
notifications: emptyNotifications(),
favorites: new Set(),
error: false,
errorData: '',
errorData: null,
timelines: {
mentions: emptyTl(),
public: emptyTl(),

View File

@ -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
}
})

View File

@ -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) {