Merge branch 'feature/flush-timeline-with-holes' into 'develop'
Clear timeline when there's holes between old and new Closes #54 See merge request pleroma/pleroma-fe!171
This commit is contained in:
commit
2431d35277
5 changed files with 48 additions and 13 deletions
|
@ -281,6 +281,8 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, use
|
|||
url += `/${tag}.json`
|
||||
}
|
||||
|
||||
params.push(['count', 20])
|
||||
|
||||
const queryString = map(params, (param) => `${param[0]}=${param[1]}`).join('&')
|
||||
url += `?${queryString}`
|
||||
|
||||
|
|
|
@ -29,12 +29,19 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false
|
|||
args['tag'] = tag
|
||||
|
||||
return apiService.fetchTimeline(args)
|
||||
.then((statuses) => update({store, statuses, timeline, showImmediately}),
|
||||
() => store.dispatch('setError', { value: true }))
|
||||
.then((statuses) => {
|
||||
if (!older && statuses.length >= 20) {
|
||||
store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId })
|
||||
}
|
||||
update({store, statuses, timeline, showImmediately})
|
||||
}, () => store.dispatch('setError', { value: true }))
|
||||
}
|
||||
|
||||
const startFetching = ({timeline = 'friends', credentials, store, userId = false, tag = false}) => {
|
||||
fetchAndUpdate({timeline, credentials, store, showImmediately: true, userId, tag})
|
||||
const rootState = store.rootState || store.state
|
||||
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
|
||||
const showImmediately = timelineData.visibleStatuses.length === 0
|
||||
fetchAndUpdate({timeline, credentials, store, showImmediately, userId, tag})
|
||||
const boundFetchAndUpdate = () => fetchAndUpdate({ timeline, credentials, store, userId, tag })
|
||||
return setInterval(boundFetchAndUpdate, 10000)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue