1
0
Fork 0
forked from srxl/akkoma-fe

Correctly calculate the newStatusesCount.

Fixes a bug when viewing an updating twkn while logged in.
This commit is contained in:
Roger Braun 2017-02-16 12:51:24 +01:00
parent 06021f4971
commit e892fffda7
2 changed files with 22 additions and 2 deletions

View file

@ -153,16 +153,18 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
}
}
// Decide if we should treat the status as new for this timeline.
let resultForCurrentTimeline
// Some statuses should only be added to the global status repository.
if (timeline && addToTimeline) {
mergeOrAdd(timelineObject.statuses, status)
resultForCurrentTimeline = mergeOrAdd(timelineObject.statuses, status)
}
if (timeline && showImmediately) {
// Add it directly to the visibleStatuses, don't change
// newStatusCount
mergeOrAdd(timelineObject.visibleStatuses, status)
} else if (timeline && addToTimeline && result.new) {
} else if (timeline && addToTimeline && resultForCurrentTimeline.new) {
// Just change newStatuscount
timelineObject.newStatusCount += 1
}

View file

@ -79,6 +79,24 @@ describe('The Statuses module', () => {
expect(state.timelines.public.newStatusCount).to.equal(1)
})
it('counts the status as new if it has not been seen on this timeline', () => {
const state = cloneDeep(defaultState)
const status = makeMockStatus({id: 1})
mutations.addNewStatuses(state, { statuses: [status], timeline: 'public' })
mutations.addNewStatuses(state, { statuses: [status], timeline: 'friends' })
expect(state.allStatuses).to.eql([status])
expect(state.timelines.public.statuses).to.eql([status])
expect(state.timelines.public.visibleStatuses).to.eql([])
expect(state.timelines.public.newStatusCount).to.equal(1)
expect(state.allStatuses).to.eql([status])
expect(state.timelines.friends.statuses).to.eql([status])
expect(state.timelines.friends.visibleStatuses).to.eql([])
expect(state.timelines.friends.newStatusCount).to.equal(1)
})
it('add the statuses to allStatuses if no timeline is given', () => {
const state = cloneDeep(defaultState)
const status = makeMockStatus({id: 1})