replace setInterval for timelne, notifications and follow requests

This commit is contained in:
Shpuld Shpuldson 2020-09-02 20:40:47 +03:00
parent acc45b49a5
commit 2d914c331e
5 changed files with 34 additions and 9 deletions

View file

@ -1,6 +1,7 @@
import { camelCase } from 'lodash'
import apiService from '../api/api.service.js'
import { makeFetcher } from '../fetcher/fetcher.js'
const update = ({ store, statuses, timeline, showImmediately, userId, pagination }) => {
const ccTimeline = camelCase(timeline)
@ -70,9 +71,9 @@ const startFetching = ({ timeline = 'friends', credentials, store, userId = fals
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
const showImmediately = timelineData.visibleStatuses.length === 0
timelineData.userId = userId
fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag })
const boundFetchAndUpdate = () => fetchAndUpdate({ timeline, credentials, store, userId, tag })
return setInterval(boundFetchAndUpdate, 10000)
const boundFetchAndUpdate = () =>
fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag })
return makeFetcher(boundFetchAndUpdate, 10000)
}
const timelineFetcher = {
fetchAndUpdate,