forked from AkkomaGang/akkoma-fe
Make minId reset with minVisibleId to prevent gaps when showing new
This commit is contained in:
parent
841648676c
commit
70d7ed3607
2 changed files with 241 additions and 220 deletions
|
@ -333,6 +333,7 @@ export const mutations = {
|
|||
oldTimeline.newStatusCount = 0
|
||||
oldTimeline.visibleStatuses = slice(oldTimeline.statuses, 0, 50)
|
||||
oldTimeline.minVisibleId = last(oldTimeline.visibleStatuses).id
|
||||
oldTimeline.minId = oldTimeline.minVisibleId
|
||||
oldTimeline.visibleStatusesObject = {}
|
||||
each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status })
|
||||
},
|
||||
|
|
|
@ -14,14 +14,15 @@ const makeMockStatus = ({id, text, type = 'status'}) => {
|
|||
}
|
||||
}
|
||||
|
||||
describe('Statuses.prepareStatus', () => {
|
||||
describe('Statuses module', () => {
|
||||
describe('prepareStatus', () => {
|
||||
it('sets deleted flag to false', () => {
|
||||
const aStatus = makeMockStatus({id: '1', text: 'Hello oniichan'})
|
||||
expect(prepareStatus(aStatus).deleted).to.eq(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('The Statuses module', () => {
|
||||
describe('addNewStatuses', () => {
|
||||
it('adds the status to allStatuses and to the given timeline', () => {
|
||||
const state = defaultState()
|
||||
const status = makeMockStatus({id: '1'})
|
||||
|
@ -238,7 +239,25 @@ describe('The Statuses module', () => {
|
|||
expect(state.timelines.public.visibleStatuses[0].fave_num).to.eql(1)
|
||||
expect(state.timelines.public.visibleStatuses[0].favorited).to.eql(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('showNewStatuses', () => {
|
||||
it('resets the minId to the min of the visible statuses when adding new to visible statuses', () => {
|
||||
const state = defaultState()
|
||||
const status = makeMockStatus({ id: '10' })
|
||||
mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' })
|
||||
const newStatus = makeMockStatus({ id: '20' })
|
||||
mutations.addNewStatuses(state, { statuses: [newStatus], showImmediately: false, timeline: 'public' })
|
||||
state.timelines.public.minId = '5'
|
||||
mutations.showNewStatuses(state, { timeline: 'public' })
|
||||
|
||||
expect(state.timelines.public.visibleStatuses.length).to.eql(2)
|
||||
expect(state.timelines.public.minVisibleId).to.eql('10')
|
||||
expect(state.timelines.public.minId).to.eql('10')
|
||||
})
|
||||
})
|
||||
|
||||
describe('clearTimeline', () => {
|
||||
it('keeps userId when clearing user timeline', () => {
|
||||
const state = defaultState()
|
||||
state.timelines.user.userId = 123
|
||||
|
@ -247,6 +266,7 @@ describe('The Statuses module', () => {
|
|||
|
||||
expect(state.timelines.user.userId).to.eql(123)
|
||||
})
|
||||
})
|
||||
|
||||
describe('notifications', () => {
|
||||
it('removes a notification when the notice gets removed', () => {
|
||||
|
|
Loading…
Reference in a new issue