Make minVisibleId actually dependent on visible statuses.

This commit is contained in:
Roger Braun 2017-01-01 18:10:25 +01:00
parent 0db25bdca0
commit c1d0b04105
2 changed files with 9 additions and 6 deletions

View File

@ -106,7 +106,7 @@ const mergeOrAdd = (arr, item) => {
const sortTimeline = (timeline) => { const sortTimeline = (timeline) => {
timeline.visibleStatuses = sortBy(timeline.visibleStatuses, ({id}) => -id) timeline.visibleStatuses = sortBy(timeline.visibleStatuses, ({id}) => -id)
timeline.statuses = sortBy(timeline.statuses, ({id}) => -id) timeline.statuses = sortBy(timeline.statuses, ({id}) => -id)
timeline.minVisibleId = (last(timeline.statuses) || {}).id timeline.minVisibleId = (last(timeline.visibleStatuses) || {}).id
return timeline return timeline
} }

View File

@ -136,18 +136,21 @@ describe('The Statuses module', () => {
it('keeps a descending by id order in timeline.visibleStatuses and timeline.statuses', () => { it('keeps a descending by id order in timeline.visibleStatuses and timeline.statuses', () => {
const state = cloneDeep(defaultState) const state = cloneDeep(defaultState)
const status = makeMockStatus({id: 2}) const nonVisibleStatus = makeMockStatus({id: 1})
const statusTwo = makeMockStatus({id: 1}) const status = makeMockStatus({id: 3})
const statusThree = makeMockStatus({id: 3}) const statusTwo = makeMockStatus({id: 2})
const statusThree = makeMockStatus({id: 4})
mutations.addNewStatuses(state, { statuses: [nonVisibleStatus], showImmediately: false, timeline: 'public' })
mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' }) mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' })
mutations.addNewStatuses(state, { statuses: [statusTwo], showImmediately: true, timeline: 'public' }) mutations.addNewStatuses(state, { statuses: [statusTwo], showImmediately: true, timeline: 'public' })
expect(state.timelines.public.minVisibleId).to.equal(1) expect(state.timelines.public.minVisibleId).to.equal(2)
mutations.addNewStatuses(state, { statuses: [statusThree], showImmediately: true, timeline: 'public' }) mutations.addNewStatuses(state, { statuses: [statusThree], showImmediately: true, timeline: 'public' })
expect(state.timelines.public.statuses).to.eql([statusThree, status, statusTwo]) expect(state.timelines.public.statuses).to.eql([statusThree, status, statusTwo, nonVisibleStatus])
expect(state.timelines.public.visibleStatuses).to.eql([statusThree, status, statusTwo]) expect(state.timelines.public.visibleStatuses).to.eql([statusThree, status, statusTwo])
}) })