diff options
| author | Shpuld Shpludson <shp@cock.li> | 2020-10-01 13:20:14 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2020-10-01 13:20:14 +0000 |
| commit | 6bd38c7d6f3b0bf7cd1bdb6f6dcb49492491c562 (patch) | |
| tree | 9a4e136d71747188ae455954ab7b620a352f4b86 /src/services/notifications_fetcher | |
| parent | 68c2a5b18f887f3db2f5685953bc5175aaaabbd3 (diff) | |
| parent | e331db79e50d4056cf61baa5ece88ad74e7e7fcf (diff) | |
Merge branch 'fix/wait-for-request-before-starting-interval' into 'develop'
Fix/wait for request before starting interval - fix #937
Closes #937
See merge request pleroma/pleroma-fe!1222
Diffstat (limited to 'src/services/notifications_fetcher')
| -rw-r--r-- | src/services/notifications_fetcher/notifications_fetcher.service.js | 8 |
1 files changed, 5 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..c908b644 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 { promiseInterval } from '../promise_interval/promise_interval.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,13 @@ 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 }) + boundFetchAndUpdate() + return promiseInterval(boundFetchAndUpdate, 10000) } const notificationsFetcher = { |
