A bit more advanced status merging.
This commit is contained in:
parent
4fcb60487c
commit
8723c35d43
@ -153,6 +153,11 @@ export const findMaxId = (...args) => {
|
|||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
addNewStatuses (state, { statuses, showImmediately = false, timeline }) {
|
addNewStatuses (state, { statuses, showImmediately = false, timeline }) {
|
||||||
|
|
||||||
|
// Merge in the new status into the old ones.
|
||||||
|
mergeStatuses(state.allStatuses, statuses)
|
||||||
|
|
||||||
|
// Get relevant timeline
|
||||||
const timelineObject = state.timelines[timeline]
|
const timelineObject = state.timelines[timeline]
|
||||||
|
|
||||||
// Set new maxId
|
// Set new maxId
|
||||||
@ -163,7 +168,6 @@ export const mutations = {
|
|||||||
// const statusesByType = groupStatusesByType(statuses)
|
// const statusesByType = groupStatusesByType(statuses)
|
||||||
|
|
||||||
state.timelines[timeline] = addStatusesToTimeline(statuses, showImmediately, state.timelines[timeline])
|
state.timelines[timeline] = addStatusesToTimeline(statuses, showImmediately, state.timelines[timeline])
|
||||||
mergeStatuses(state.allStatuses, state.timelines[timeline].statuses)
|
|
||||||
|
|
||||||
// Set up retweets with most current status
|
// Set up retweets with most current status
|
||||||
const getRetweets = (result, status) => {
|
const getRetweets = (result, status) => {
|
||||||
@ -175,7 +179,9 @@ export const mutations = {
|
|||||||
|
|
||||||
const retweets = reduce(statuses, getRetweets, [])
|
const retweets = reduce(statuses, getRetweets, [])
|
||||||
|
|
||||||
state.allStatuses = unionBy(retweets, state.allStatuses, 'id')
|
// state.allStatuses = unionBy(retweets, state.allStatuses, 'id')
|
||||||
|
|
||||||
|
mergeStatuses(state.allStatuses, retweets)
|
||||||
|
|
||||||
each(state.allStatuses, (status) => {
|
each(state.allStatuses, (status) => {
|
||||||
if (status.retweeted_status) {
|
if (status.retweeted_status) {
|
||||||
|
@ -86,11 +86,11 @@ describe('The Statuses module', () => {
|
|||||||
// It adds both statuses, but only the retweet to visible.
|
// It adds both statuses, but only the retweet to visible.
|
||||||
mutations.addNewStatuses(state, { statuses: [retweet], timeline: 'public', showImmediately: true })
|
mutations.addNewStatuses(state, { statuses: [retweet], timeline: 'public', showImmediately: true })
|
||||||
expect(state.timelines.public.visibleStatuses).to.have.length(1)
|
expect(state.timelines.public.visibleStatuses).to.have.length(1)
|
||||||
expect(state.allStatuses).to.eql([status, retweet])
|
expect(state.allStatuses).to.eql([retweet, status])
|
||||||
|
|
||||||
// It refers to the modified status.
|
// It refers to the modified status.
|
||||||
mutations.addNewStatuses(state, { statuses: [modStatus], timeline: 'public' })
|
mutations.addNewStatuses(state, { statuses: [modStatus], timeline: 'public' })
|
||||||
expect(state.allStatuses).to.eql([modStatus, retweet])
|
expect(state.allStatuses).to.eql([retweet, modStatus])
|
||||||
expect(retweet.retweeted_status).to.eql(modStatus)
|
expect(retweet.retweeted_status).to.eql(modStatus)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ describe('The Statuses module', () => {
|
|||||||
mutations.addNewStatuses(state, { statuses: [retweet], showImmediately: false, timeline: 'public' })
|
mutations.addNewStatuses(state, { statuses: [retweet], showImmediately: false, timeline: 'public' })
|
||||||
expect(state.timelines.public.visibleStatuses).to.have.length(1)
|
expect(state.timelines.public.visibleStatuses).to.have.length(1)
|
||||||
expect(state.allStatuses).to.have.length(2)
|
expect(state.allStatuses).to.have.length(2)
|
||||||
expect(state.allStatuses[0]).to.equal(modStatus)
|
expect(state.allStatuses[0]).to.eql(modStatus)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('handles favorite actions', () => {
|
it('handles favorite actions', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user