diff options
| author | eal <eal@waifu.club> | 2017-12-23 19:52:16 +0200 |
|---|---|---|
| committer | eal <eal@waifu.club> | 2017-12-23 19:52:16 +0200 |
| commit | b67c50606250d2c2d4b3750affdbab6525872f2a (patch) | |
| tree | bb45758ecab1ef87976c07d37b6936a3531e2b13 /src/services/timeline_fetcher/timeline_fetcher.service.js | |
| parent | 581e3e836ad6c8a9a211eb09d7eaa1fbaf830da2 (diff) | |
| parent | 6fd309452a1d8243257bc8544429ea53a26ce8a4 (diff) | |
Merge branch 'develop' into feature/normal-emoji-completion
Diffstat (limited to 'src/services/timeline_fetcher/timeline_fetcher.service.js')
| -rw-r--r-- | src/services/timeline_fetcher/timeline_fetcher.service.js | 13 |
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) } |
