2019-02-27 14:38:10 -05:00
|
|
|
import apiService from '../api/api.service.js'
|
|
|
|
|
|
|
|
const fetchAndUpdate = ({ store, credentials }) => {
|
|
|
|
return apiService.fetchFollowRequests({ credentials })
|
|
|
|
.then((requests) => {
|
|
|
|
store.commit('setFollowRequests', requests)
|
|
|
|
}, () => {})
|
|
|
|
.catch(() => {})
|
|
|
|
}
|
|
|
|
|
2019-07-05 10:02:14 +03:00
|
|
|
const startFetching = ({ credentials, store }) => {
|
2019-02-27 14:38:10 -05:00
|
|
|
fetchAndUpdate({ credentials, store })
|
|
|
|
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
|
|
|
return setInterval(boundFetchAndUpdate, 10000)
|
|
|
|
}
|
|
|
|
|
2019-02-28 12:53:37 -05:00
|
|
|
const followRequestFetcher = {
|
2019-02-27 14:38:10 -05:00
|
|
|
startFetching
|
|
|
|
}
|
|
|
|
|
2019-02-28 12:53:37 -05:00
|
|
|
export default followRequestFetcher
|