fixes to timeline error handling

This commit is contained in:
Shpuld Shpuldson 2020-11-10 12:52:54 +02:00
parent e6ca489d30
commit d150dae5d1
7 changed files with 20 additions and 42 deletions

View file

@ -560,7 +560,7 @@ const fetchTimeline = ({
})
.then((data) => data.json())
.then((data) => {
if (!data.error) {
if (!data.errors) {
return { data: data.map(isNotifications ? parseNotification : parseStatus), pagination }
} else {
data.status = status

View file

@ -52,9 +52,8 @@ const fetchAndUpdate = ({
return apiService.fetchTimeline(args)
.then(response => {
if (response.error) {
store.dispatch('setErrorData', { value: response })
return
if (response.errors) {
throw new Error(`${response.status} ${response.statusText}`)
}
const { data: statuses, pagination } = response
@ -63,7 +62,15 @@ const fetchAndUpdate = ({
}
update({ store, statuses, timeline, showImmediately, userId, pagination })
return { statuses, pagination }
}, () => store.dispatch('setError', { value: true }))
})
.catch((error) => {
store.dispatch('pushGlobalNotice', {
level: 'error',
messageKey: 'timeline.error',
messageArgs: [error.message],
timeout: 5000
})
})
}
const startFetching = ({ timeline = 'friends', credentials, store, userId = false, tag = false }) => {