aboutsummaryrefslogtreecommitdiff
path: root/src/services/notifications_fetcher
diff options
context:
space:
mode:
authorShpuld Shpludson <shp@cock.li>2020-11-18 11:49:54 +0000
committerShpuld Shpludson <shp@cock.li>2020-11-18 11:49:54 +0000
commitd770bab1b0e5d543547c59d86aef533f77ceafe2 (patch)
treeb8e34c857f3acf526f2f5422a995803ef85cd51a /src/services/notifications_fetcher
parentcd784396e72dafc8442ac48635ea23f8365d83bd (diff)
parentfb5d3d32927cd9ad625203c84e8826a3544fda3e (diff)
Merge branch 'fix/timeline-error-handling-fixes' into 'develop'
Various timeline fixes See merge request pleroma/pleroma-fe!1283
Diffstat (limited to 'src/services/notifications_fetcher')
-rw-r--r--src/services/notifications_fetcher/notifications_fetcher.service.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js
index c908b644..beeb167c 100644
--- a/src/services/notifications_fetcher/notifications_fetcher.service.js
+++ b/src/services/notifications_fetcher/notifications_fetcher.service.js
@@ -2,7 +2,6 @@ import apiService from '../api/api.service.js'
import { promiseInterval } from '../promise_interval/promise_interval.js'
const update = ({ store, notifications, older }) => {
- store.dispatch('setNotificationsError', { value: false })
store.dispatch('addNewNotifications', { notifications, older })
}
@@ -47,11 +46,22 @@ const fetchAndUpdate = ({ store, credentials, older = false }) => {
const fetchNotifications = ({ store, args, older }) => {
return apiService.fetchTimeline(args)
- .then(({ data: notifications }) => {
+ .then((response) => {
+ if (response.errors) {
+ throw new Error(`${response.status} ${response.statusText}`)
+ }
+ const notifications = response.data
update({ store, notifications, older })
return notifications
- }, () => store.dispatch('setNotificationsError', { value: true }))
- .catch(() => store.dispatch('setNotificationsError', { value: true }))
+ })
+ .catch((error) => {
+ store.dispatch('pushGlobalNotice', {
+ level: 'error',
+ messageKey: 'notifications.error',
+ messageArgs: [error.message],
+ timeout: 5000
+ })
+ })
}
const startFetching = ({ credentials, store }) => {