Fix mistake in flushMarker init, make startFetching behave properly with older statuses existing.

This commit is contained in:
shpuld 2017-11-23 13:46:37 +02:00
parent 912be5aed9
commit 6b773902e8
3 changed files with 20 additions and 11 deletions

View File

@ -31,7 +31,7 @@ const Timeline = {
return this.timeline.newStatusCount
},
newStatusCountStr () {
if (this.timeline.flushMarker > 0) {
if (this.timeline.flushMarker !== 0) {
return ''
} else {
return ` (${this.newStatusCount})`
@ -71,7 +71,7 @@ const Timeline = {
},
methods: {
showNewStatuses () {
if (this.timeline.flushMarker) {
if (this.timeline.flushMarker !== 0) {
this.$store.commit('clearTimeline', { timeline: this.timelineName })
this.$store.commit('queueFlush', { timeline: this.timelineName, id: 0 })
this.fetchOlderStatuses()

View File

@ -9,7 +9,6 @@ export const defaultState = {
notifications: [],
favorites: new Set(),
error: false,
flushMarker: 0,
timelines: {
mentions: {
statuses: [],
@ -23,7 +22,8 @@ export const defaultState = {
loading: false,
followers: [],
friends: [],
viewing: 'statuses'
viewing: 'statuses',
flushMarker: 0
},
public: {
statuses: [],
@ -37,7 +37,8 @@ export const defaultState = {
loading: false,
followers: [],
friends: [],
viewing: 'statuses'
viewing: 'statuses',
flushMarker: 0
},
user: {
statuses: [],
@ -51,7 +52,8 @@ export const defaultState = {
loading: false,
followers: [],
friends: [],
viewing: 'statuses'
viewing: 'statuses',
flushMarker: 0
},
publicAndExternal: {
statuses: [],
@ -65,7 +67,8 @@ export const defaultState = {
loading: false,
followers: [],
friends: [],
viewing: 'statuses'
viewing: 'statuses',
flushMarker: 0
},
friends: {
statuses: [],
@ -79,7 +82,8 @@ export const defaultState = {
loading: false,
followers: [],
friends: [],
viewing: 'statuses'
viewing: 'statuses',
flushMarker: 0
},
tag: {
statuses: [],
@ -93,7 +97,8 @@ export const defaultState = {
loading: false,
followers: [],
friends: [],
viewing: 'statuses'
viewing: 'statuses',
flushMarker: 0
}
}
}
@ -382,7 +387,8 @@ export const mutations = {
loading: false,
followers: [],
friends: [],
viewing: 'statuses'
viewing: 'statuses',
flushMarker: 0
}
state.timelines[timeline] = emptyTimeline

View File

@ -38,7 +38,10 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false
}
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)
}