aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshpuld <shp@cock.li>2017-11-21 16:12:47 +0200
committershpuld <shp@cock.li>2017-11-21 16:12:47 +0200
commitfc1736618b4e1a9f178c0ae287754c6ac1244b08 (patch)
tree08d5d4d05ddce8c9ec8f5ff48e55e1e4697f60c7
parent80203636803c3035a46d0d82c7778e4aff8d2612 (diff)
attempt to recognize when holes in timeline for various reasons, clear timeline and fetch older when showing new to get rid of holes
-rw-r--r--src/components/timeline/timeline.js17
-rw-r--r--src/components/timeline/timeline.vue2
-rw-r--r--src/modules/statuses.js7
-rw-r--r--src/services/api/api.service.js2
-rw-r--r--src/services/timeline_fetcher/timeline_fetcher.service.js8
5 files changed, 31 insertions, 5 deletions
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js
index be0aefc1..9ef8406b 100644
--- a/src/components/timeline/timeline.js
+++ b/src/components/timeline/timeline.js
@@ -29,6 +29,13 @@ const Timeline = {
},
newStatusCount () {
return this.timeline.newStatusCount
+ },
+ newStatusCountStr () {
+ if (this.timeline.flushMarker) {
+ return ''
+ } else {
+ return ` (${this.newStatusCount})`
+ }
}
},
components: {
@@ -64,8 +71,14 @@ const Timeline = {
},
methods: {
showNewStatuses () {
- this.$store.commit('showNewStatuses', { timeline: this.timelineName })
- this.paused = false
+ if (this.timeline.flushMarker) {
+ this.$store.commit('clearTimeline', { timeline: this.timelineName })
+ this.$store.commit('queueFlush', { timeline: this.timelineName, id: 0 })
+ this.fetchOlderStatuses()
+ } else {
+ this.$store.commit('showNewStatuses', { timeline: this.timelineName })
+ this.paused = false
+ }
},
fetchOlderStatuses () {
const store = this.$store
diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue
index 0e2ed92c..365c8236 100644
--- a/src/components/timeline/timeline.vue
+++ b/src/components/timeline/timeline.vue
@@ -5,7 +5,7 @@
{{title}}
</div>
<button @click.prevent="showNewStatuses" class="base05 base02-background loadmore-button" v-if="timeline.newStatusCount > 0 && !timelineError">
- {{$t('timeline.show_new')}} ({{timeline.newStatusCount}})
+ {{$t('timeline.show_new')}}{{timeline.newStatusMsg}}
</button>
<div @click.prevent class="base06 error loadmore-text" v-if="timelineError">
{{$t('timeline.error_fetching')}}
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index d954b023..82a7eda1 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -9,6 +9,7 @@ export const defaultState = {
notifications: [],
favorites: new Set(),
error: false,
+ flushMarker: 0,
timelines: {
mentions: {
statuses: [],
@@ -422,6 +423,9 @@ export const mutations = {
each(notifications, (notification) => {
notification.seen = true
})
+ },
+ queueFlush (state, { timeline, id }) {
+ state.timelines[timeline].flushMarker = id
}
}
@@ -458,6 +462,9 @@ const statuses = {
// Optimistic retweeting...
commit('setRetweeted', { status, value: true })
apiService.retweet({ id: status.id, credentials: rootState.users.currentUser.credentials })
+ },
+ queueFlush ({ rootState, commit }, { timeline, id }) {
+ commit('queueFlush', { timeline, id })
}
},
mutations
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index 5de0a457..fa95b870 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -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}`
diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js
index 6b76eb54..a02d67d0 100644
--- a/src/services/timeline_fetcher/timeline_fetcher.service.js
+++ b/src/services/timeline_fetcher/timeline_fetcher.service.js
@@ -29,8 +29,12 @@ 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}) => {