aboutsummaryrefslogtreecommitdiff
path: root/src/services/timeline_fetcher/timeline_fetcher.service.js
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2017-11-24 07:30:17 +0000
committerlambda <pleromagit@rogerbraun.net>2017-11-24 07:30:17 +0000
commit2431d35277b0c7c761bf080f0bfffa654ee4b182 (patch)
treeb88d02bfb78b4f733e71f975c5da9203468f20da /src/services/timeline_fetcher/timeline_fetcher.service.js
parent38cab5e4b695eea90b01c2866976960e9fc01128 (diff)
parent6b773902e8dae36b2c4cf4c970fd1437cfdc13bc (diff)
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
Diffstat (limited to 'src/services/timeline_fetcher/timeline_fetcher.service.js')
-rw-r--r--src/services/timeline_fetcher/timeline_fetcher.service.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js
index 6b76eb54..a4a80df0 100644
--- a/src/services/timeline_fetcher/timeline_fetcher.service.js
+++ b/src/services/timeline_fetcher/timeline_fetcher.service.js
@@ -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)
}