Correctly calculate the newStatusesCount.
Fixes a bug when viewing an updating twkn while logged in.
This commit is contained in:
parent
06021f4971
commit
e892fffda7
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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})
|
||||
|
|
Loading…
Reference in New Issue