aboutsummaryrefslogtreecommitdiff
path: root/src/services/notifications_fetcher/request_fetcher.service.js
blob: beb6c320ddc022700fe616c3c779ab828ed652c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import apiService from '../api/api.service.js'

const fetchAndUpdate = ({ store, credentials }) => {
  return apiService.fetchFollowRequests({ credentials })
    .then((requests) => {
      store.commit('setFollowRequests', requests)
    }, () => {})
    .catch(() => {})
}

const startFetching = ({credentials, store}) => {
  fetchAndUpdate({ credentials, store })
  const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
  return setInterval(boundFetchAndUpdate, 10000)
}

const requestFetcher = {
  startFetching
}

export default requestFetcher