aboutsummaryrefslogtreecommitdiff
path: root/src/services/notifications_fetcher
diff options
context:
space:
mode:
authorShpuld Shpuldson <shp@cock.li>2020-09-02 20:40:47 +0300
committerShpuld Shpuldson <shp@cock.li>2020-09-02 20:40:47 +0300
commit2d914c331eea5f5b9036e10ef3d937628891b9e1 (patch)
treefaee1fb83a9d71e4f43a4e8ea4232c2cf543b84d /src/services/notifications_fetcher
parentacc45b49a55a5c173abdeac8c89d16395f92bc01 (diff)
replace setInterval for timelne, notifications and follow requests
Diffstat (limited to 'src/services/notifications_fetcher')
-rw-r--r--src/services/notifications_fetcher/notifications_fetcher.service.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js
index 80be02ca..2a3a17be 100644
--- a/src/services/notifications_fetcher/notifications_fetcher.service.js
+++ b/src/services/notifications_fetcher/notifications_fetcher.service.js
@@ -1,4 +1,5 @@
import apiService from '../api/api.service.js'
+import makeFetcher from '../fetcher/fetcher.js'
const update = ({ store, notifications, older }) => {
store.dispatch('setNotificationsError', { value: false })
@@ -39,6 +40,7 @@ const fetchAndUpdate = ({ store, credentials, older = false }) => {
args['since'] = Math.max(...readNotifsIds)
fetchNotifications({ store, args, older })
}
+
return result
}
}
@@ -53,13 +55,12 @@ const fetchNotifications = ({ store, args, older }) => {
}
const startFetching = ({ credentials, store }) => {
- fetchAndUpdate({ credentials, store })
- const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
// Initially there's set flag to silence all desktop notifications so
// that there won't spam of them when user just opened up the FE we
// reset that flag after a while to show new notifications once again.
setTimeout(() => store.dispatch('setNotificationsSilence', false), 10000)
- return setInterval(boundFetchAndUpdate, 10000)
+ const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store, refetch: true })
+ return makeFetcher(boundFetchAndUpdate, 10000)
}
const notificationsFetcher = {