aboutsummaryrefslogtreecommitdiff
path: root/src/services/follow_request_fetcher/follow_request_fetcher.service.js
blob: 786740b7e2e5688a31a3e1d5cbdbca686691552a (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 followRequestFetcher = {
  startFetching
}

export default followRequestFetcher