fix timeline showimmediately being set wrongly

This commit is contained in:
Shpuld Shpuldson 2020-09-02 22:12:50 +03:00
parent 4d080a1654
commit 5b403ba7d1
4 changed files with 9 additions and 6 deletions

View file

@ -1,9 +1,9 @@
// makeFetcher - replacement for setInterval for fetching, starts counting // makeFetcher - replacement for setInterval for fetching, starts counting
// the interval only after a request is done instead of immediately. // the interval only after a request is done instead of immediately.
// promiseCall is a function that returns a promise, it's called when created // - promiseCall is a function that returns a promise, it's called the first
// and after every interval. // time after the first interval.
// interval is the interval delay in ms. // - interval is the interval delay in ms.
export const makeFetcher = (promiseCall, interval) => { export const makeFetcher = (promiseCall, interval) => {
let stopped = false let stopped = false
@ -22,7 +22,7 @@ export const makeFetcher = (promiseCall, interval) => {
window.clearTimeout(timeout) window.clearTimeout(timeout)
} }
func() timeout = window.setTimeout(func, interval)
return stopFetcher return stopFetcher
} }

View file

@ -12,6 +12,7 @@ const fetchAndUpdate = ({ store, credentials }) => {
const startFetching = ({ credentials, store }) => { const startFetching = ({ credentials, store }) => {
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store }) const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
boundFetchAndUpdate()
return makeFetcher(boundFetchAndUpdate, 10000) return makeFetcher(boundFetchAndUpdate, 10000)
} }

View file

@ -59,7 +59,8 @@ const startFetching = ({ credentials, store }) => {
// that there won't spam of them when user just opened up the FE we // that there won't spam of them when user just opened up the FE we
// reset that flag after a while to show new notifications once again. // reset that flag after a while to show new notifications once again.
setTimeout(() => store.dispatch('setNotificationsSilence', false), 10000) setTimeout(() => store.dispatch('setNotificationsSilence', false), 10000)
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store, refetch: true }) const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
boundFetchAndUpdate()
return makeFetcher(boundFetchAndUpdate, 10000) return makeFetcher(boundFetchAndUpdate, 10000)
} }

View file

@ -71,8 +71,9 @@ const startFetching = ({ timeline = 'friends', credentials, store, userId = fals
const timelineData = rootState.statuses.timelines[camelCase(timeline)] const timelineData = rootState.statuses.timelines[camelCase(timeline)]
const showImmediately = timelineData.visibleStatuses.length === 0 const showImmediately = timelineData.visibleStatuses.length === 0
timelineData.userId = userId timelineData.userId = userId
const boundFetchAndUpdate = () =>
fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag }) fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag })
const boundFetchAndUpdate = () =>
fetchAndUpdate({ timeline, credentials, store, userId, tag })
return makeFetcher(boundFetchAndUpdate, 10000) return makeFetcher(boundFetchAndUpdate, 10000)
} }
const timelineFetcher = { const timelineFetcher = {