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

View file

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