2019-02-27 19:38:10 +00:00
|
|
|
import apiService from '../api/api.service.js'
|
2020-09-04 08:19:53 +00:00
|
|
|
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
2019-02-27 19:38:10 +00:00
|
|
|
|
|
|
|
const fetchAndUpdate = ({ store, credentials }) => {
|
|
|
|
return apiService.fetchFollowRequests({ credentials })
|
|
|
|
.then((requests) => {
|
|
|
|
store.commit('setFollowRequests', requests)
|
2020-07-02 09:19:33 +00:00
|
|
|
store.commit('addNewUsers', requests)
|
2019-02-27 19:38:10 +00:00
|
|
|
}, () => {})
|
|
|
|
.catch(() => {})
|
|
|
|
}
|
|
|
|
|
2019-07-05 07:02:14 +00:00
|
|
|
const startFetching = ({ credentials, store }) => {
|
2019-02-27 19:38:10 +00:00
|
|
|
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
2020-09-02 19:12:50 +00:00
|
|
|
boundFetchAndUpdate()
|
2020-09-04 08:19:53 +00:00
|
|
|
return promiseInterval(boundFetchAndUpdate, 10000)
|
2019-02-27 19:38:10 +00:00
|
|
|
}
|
|
|
|
|
2019-02-28 17:53:37 +00:00
|
|
|
const followRequestFetcher = {
|
2019-02-27 19:38:10 +00:00
|
|
|
startFetching
|
|
|
|
}
|
|
|
|
|
2019-02-28 17:53:37 +00:00
|
|
|
export default followRequestFetcher
|