Merge pull request #1097 from h3poteto/iss-1096

closes #1096 Reject duplicated status when append statuses in mutations
This commit is contained in:
AkiraFukushima 2019-11-13 23:52:43 +09:00 committed by GitHub
commit 0e66bba0c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 793 additions and 239 deletions

View File

@ -85,6 +85,38 @@ const status2: Status = {
pinned: null
}
const rebloggedStatus: Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
in_reply_to_id: null,
in_reply_to_account_id: null,
reblog: status1,
content: '',
created_at: '2019-03-31T21:40:32',
emojis: [],
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
reblogged: null,
favourited: null,
muted: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null,
application: {
name: 'Web'
} as Application,
language: null,
pinned: null
}
describe('TimelineSpace/Contents/DirectMessages', () => {
describe('mutations', () => {
let state: DirectMessagesState
@ -108,37 +140,6 @@ describe('TimelineSpace/Contents/DirectMessages', () => {
describe('message is reblogged', () => {
beforeEach(() => {
const rebloggedStatus: Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
in_reply_to_id: null,
in_reply_to_account_id: null,
reblog: status1,
content: '',
created_at: '2019-03-31T21:40:32',
emojis: [],
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
reblogged: null,
favourited: null,
muted: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null,
application: {
name: 'Web'
} as Application,
language: null,
pinned: null
}
state = {
lazyLoading: false,
heading: true,
@ -153,5 +154,79 @@ describe('TimelineSpace/Contents/DirectMessages', () => {
})
})
})
describe('appendTimeline', () => {
describe('heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should be updated timeline', () => {
DirectMessages.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [rebloggedStatus, status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should not be updated timeline', () => {
DirectMessages.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
})
describe('not heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should be updated timeline', () => {
DirectMessages.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([status2, status1])
expect(state.unreadTimeline).toEqual([rebloggedStatus])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [rebloggedStatus, status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should not be updated timeline', () => {
DirectMessages.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
})
})
})
})

View File

@ -85,6 +85,38 @@ const status2: Status = {
pinned: null
}
const rebloggedStatus: Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
in_reply_to_id: null,
in_reply_to_account_id: null,
reblog: status1,
content: '',
created_at: '2019-03-31T21:40:32',
emojis: [],
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
reblogged: null,
favourited: null,
muted: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null,
application: {
name: 'Web'
} as Application,
language: null,
pinned: null
}
describe('TimelineSpace/Contents/Hashtag/Tag', () => {
describe('mutations', () => {
let state: TagState
@ -108,37 +140,6 @@ describe('TimelineSpace/Contents/Hashtag/Tag', () => {
describe('message is reblogged', () => {
beforeEach(() => {
const rebloggedStatus: Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
in_reply_to_id: null,
in_reply_to_account_id: null,
reblog: status1,
content: '',
created_at: '2019-03-31T21:40:32',
emojis: [],
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
reblogged: null,
favourited: null,
muted: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null,
application: {
name: 'Web'
} as Application,
language: null,
pinned: null
}
state = {
lazyLoading: false,
heading: true,
@ -153,5 +154,79 @@ describe('TimelineSpace/Contents/Hashtag/Tag', () => {
})
})
})
describe('appendTimeline', () => {
describe('heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should be updated timeline', () => {
Tag.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [rebloggedStatus, status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should not be updated timeline', () => {
Tag.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
})
describe('not heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should be updated timeline', () => {
Tag.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([status2, status1])
expect(state.unreadTimeline).toEqual([rebloggedStatus])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [rebloggedStatus, status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should not be updated timeline', () => {
Tag.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
})
})
})
})

View File

@ -116,40 +116,81 @@ describe('TimelineSpace/Contents/Home', () => {
describe('appendTimeline', () => {
describe('heading', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [status1],
unreadTimeline: [],
filter: '',
showReblogs: true,
showReplies: true
}
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [status1],
unreadTimeline: [],
filter: '',
showReblogs: true,
showReplies: true
}
})
it('should update timeline', () => {
Home.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, status2)
expect(state.timeline).toEqual([status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
it('should update timeline', () => {
Home.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, status2)
expect(state.timeline).toEqual([status2, status1])
expect(state.unreadTimeline).toEqual([])
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [status2, status1],
unreadTimeline: [],
filter: '',
showReblogs: true,
showReplies: true
}
})
it('should not update timeline', () => {
Home.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, status2)
expect(state.timeline).toEqual([status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
})
describe('not heading', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [status1],
unreadTimeline: [],
filter: '',
showReblogs: true,
showReplies: true
}
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [status1],
unreadTimeline: [],
filter: '',
showReblogs: true,
showReplies: true
}
})
it('should update unreadTimeline', () => {
Home.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, status2)
expect(state.timeline).toEqual([status1])
expect(state.unreadTimeline).toEqual([status2])
})
})
it('should update unreadTimeline', () => {
Home.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, status2)
expect(state.timeline).toEqual([status1])
expect(state.unreadTimeline).toEqual([status2])
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [],
unreadTimeline: [status2, status1],
filter: '',
showReblogs: true,
showReplies: true
}
})
it('should not update unreadTimeline', () => {
Home.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, status2)
expect(state.timeline).toEqual([])
expect(state.unreadTimeline).toEqual([status2, status1])
})
})
})
})

View File

@ -85,6 +85,38 @@ const status2: Status = {
pinned: null
}
const rebloggedStatus: Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
in_reply_to_id: null,
in_reply_to_account_id: null,
reblog: status1,
content: '',
created_at: '2019-03-31T21:40:32',
emojis: [],
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
reblogged: null,
favourited: null,
muted: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null,
application: {
name: 'Web'
} as Application,
language: null,
pinned: null
}
describe('TimelineSpace/Contents/Lists/Show', () => {
describe('mutations', () => {
let state: ShowState
@ -108,37 +140,6 @@ describe('TimelineSpace/Contents/Lists/Show', () => {
describe('message is reblogged', () => {
beforeEach(() => {
const rebloggedStatus: Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
in_reply_to_id: null,
in_reply_to_account_id: null,
reblog: status1,
content: '',
created_at: '2019-03-31T21:40:32',
emojis: [],
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
reblogged: null,
favourited: null,
muted: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null,
application: {
name: 'Web'
} as Application,
language: null,
pinned: null
}
state = {
lazyLoading: false,
heading: true,
@ -153,5 +154,79 @@ describe('TimelineSpace/Contents/Lists/Show', () => {
})
})
})
describe('appendTimeline', () => {
describe('heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should be updated timeline', () => {
Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [rebloggedStatus, status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should not be updated timeline', () => {
Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
})
describe('not heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should be updated timeline', () => {
Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([status2, status1])
expect(state.unreadTimeline).toEqual([rebloggedStatus])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [rebloggedStatus, status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should not be updated timeline', () => {
Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
})
})
})
})

View File

@ -85,6 +85,38 @@ const status2: Status = {
pinned: null
}
const rebloggedStatus: Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
in_reply_to_id: null,
in_reply_to_account_id: null,
reblog: status1,
content: '',
created_at: '2019-03-31T21:40:32',
emojis: [],
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
reblogged: null,
favourited: null,
muted: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null,
application: {
name: 'Web'
} as Application,
language: null,
pinned: null
}
describe('TimelineSpace/Contents/Local', () => {
describe('mutations', () => {
let state: LocalState
@ -108,37 +140,6 @@ describe('TimelineSpace/Contents/Local', () => {
describe('message is reblogged', () => {
beforeEach(() => {
const rebloggedStatus: Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
in_reply_to_id: null,
in_reply_to_account_id: null,
reblog: status1,
content: '',
created_at: '2019-03-31T21:40:32',
emojis: [],
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
reblogged: null,
favourited: null,
muted: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null,
application: {
name: 'Web'
} as Application,
language: null,
pinned: null
}
state = {
lazyLoading: false,
heading: true,
@ -153,5 +154,78 @@ describe('TimelineSpace/Contents/Local', () => {
})
})
})
describe('appendTimeline', () => {
describe('heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should be updated timeline', () => {
Local.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [rebloggedStatus, status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should not be updated timeline', () => {
Local.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
})
describe('not heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should be updated timeline', () => {
Local.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([status2, status1])
expect(state.unreadTimeline).toEqual([rebloggedStatus])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [rebloggedStatus, status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should not be updated timeline', () => {
Local.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
})
})
})
})

View File

@ -172,35 +172,74 @@ describe('TimelineSpace/Contents/Mentions', () => {
describe('appendMentions', () => {
describe('heading', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
mentions: [notification1],
unreadMentions: [],
filter: ''
}
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
mentions: [notification1],
unreadMentions: [],
filter: ''
}
})
it('should update mentions', () => {
Mentions.mutations![MUTATION_TYPES.APPEND_MENTIONS](state, notification2)
expect(state.mentions).toEqual([notification2, notification1])
expect(state.unreadMentions).toEqual([])
})
})
it('should update mentions', () => {
Mentions.mutations![MUTATION_TYPES.APPEND_MENTIONS](state, notification2)
expect(state.mentions).toEqual([notification2, notification1])
expect(state.unreadMentions).toEqual([])
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
mentions: [notification2, notification1],
unreadMentions: [],
filter: ''
}
})
it('should not be updated mentions', () => {
Mentions.mutations![MUTATION_TYPES.APPEND_MENTIONS](state, notification2)
expect(state.mentions).toEqual([notification2, notification1])
expect(state.unreadMentions).toEqual([])
})
})
})
describe('not heading', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
mentions: [notification1],
unreadMentions: [],
filter: ''
}
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
mentions: [notification1],
unreadMentions: [],
filter: ''
}
})
it('should update mentions', () => {
Mentions.mutations![MUTATION_TYPES.APPEND_MENTIONS](state, notification2)
expect(state.mentions).toEqual([notification1])
expect(state.unreadMentions).toEqual([notification2])
})
})
it('should update mentions', () => {
Mentions.mutations![MUTATION_TYPES.APPEND_MENTIONS](state, notification2)
expect(state.mentions).toEqual([notification1])
expect(state.unreadMentions).toEqual([notification2])
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
mentions: [notification1],
unreadMentions: [notification2],
filter: ''
}
})
it('should not be updated mentions', () => {
Mentions.mutations![MUTATION_TYPES.APPEND_MENTIONS](state, notification2)
expect(state.mentions).toEqual([notification1])
expect(state.unreadMentions).toEqual([notification2])
})
})
})
})

View File

@ -184,5 +184,78 @@ describe('TimelineSpace/Contents/Notifications', () => {
})
})
})
describe('appendTimeline', () => {
describe('heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
notifications: [notification1],
unreadNotifications: [],
filter: ''
}
})
it('should update timeline', () => {
Notifications.mutations![MUTATION_TYPES.APPEND_NOTIFICATIONS](state, notification2)
expect(state.notifications).toEqual([notification2, notification1])
expect(state.unreadNotifications).toEqual([])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
notifications: [notification2, notification1],
unreadNotifications: [],
filter: ''
}
})
it('should not update timeline', () => {
Notifications.mutations![MUTATION_TYPES.APPEND_NOTIFICATIONS](state, notification2)
expect(state.notifications).toEqual([notification2, notification1])
expect(state.unreadNotifications).toEqual([])
})
})
})
describe('not heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
notifications: [notification1],
unreadNotifications: [],
filter: ''
}
})
it('should update unreadTimeline', () => {
Notifications.mutations![MUTATION_TYPES.APPEND_NOTIFICATIONS](state, notification2)
expect(state.notifications).toEqual([notification1])
expect(state.unreadNotifications).toEqual([notification2])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
notifications: [notification1],
unreadNotifications: [notification2],
filter: ''
}
})
it('should not update unreadTimeline', () => {
Notifications.mutations![MUTATION_TYPES.APPEND_NOTIFICATIONS](state, notification2)
expect(state.notifications).toEqual([notification1])
expect(state.unreadNotifications).toEqual([notification2])
})
})
})
})
})
})

View File

@ -85,6 +85,38 @@ const status2: Status = {
pinned: null
}
const rebloggedStatus: Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
in_reply_to_id: null,
in_reply_to_account_id: null,
reblog: status1,
content: '',
created_at: '2019-03-31T21:40:32',
emojis: [],
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
reblogged: null,
favourited: null,
muted: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null,
application: {
name: 'Web'
} as Application,
language: null,
pinned: null
}
describe('TimelineSpace/Contents/Local', () => {
describe('mutations', () => {
let state: PublicState
@ -108,37 +140,6 @@ describe('TimelineSpace/Contents/Local', () => {
describe('message is reblogged', () => {
beforeEach(() => {
const rebloggedStatus: Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
in_reply_to_id: null,
in_reply_to_account_id: null,
reblog: status1,
content: '',
created_at: '2019-03-31T21:40:32',
emojis: [],
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
reblogged: null,
favourited: null,
muted: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null,
application: {
name: 'Web'
} as Application,
language: null,
pinned: null
}
state = {
lazyLoading: false,
heading: true,
@ -153,5 +154,79 @@ describe('TimelineSpace/Contents/Local', () => {
})
})
})
describe('appendTimeline', () => {
describe('heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should be updated timeline', () => {
Public.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: true,
timeline: [rebloggedStatus, status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should not be updated timeline', () => {
Public.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
})
describe('not heading', () => {
describe('normal', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should be updated timeline', () => {
Public.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([status2, status1])
expect(state.unreadTimeline).toEqual([rebloggedStatus])
})
})
describe('duplicated status', () => {
beforeEach(() => {
state = {
lazyLoading: false,
heading: false,
timeline: [rebloggedStatus, status2, status1],
unreadTimeline: [],
filter: ''
}
})
it('should not be updated timeline', () => {
Public.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
expect(state.unreadTimeline).toEqual([])
})
})
})
})
})
})

View File

@ -40,10 +40,13 @@ const mutations: MutationTree<DirectMessagesState> = {
state.heading = value
},
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
// Reject duplicated status in timeline
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
}
}
},
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, messages: Array<Status>) => {

View File

@ -39,10 +39,13 @@ const mutations: MutationTree<TagState> = {
state.heading = value
},
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
// Reject duplicated status in timeline
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
}
}
},
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, timeline: Array<Status>) => {

View File

@ -46,10 +46,13 @@ const mutations: MutationTree<HomeState> = {
state.heading = value
},
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
// Reject duplicated status in timeline
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
}
}
},
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, messages: Array<Status>) => {

View File

@ -39,10 +39,13 @@ const mutations: MutationTree<ShowState> = {
state.heading = value
},
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
// Reject duplicated status in timeline
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
}
}
},
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, timeline: Array<Status>) => {

View File

@ -37,10 +37,13 @@ const mutations: MutationTree<LocalState> = {
state.heading = value
},
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
// Reject duplicated status in timeline
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
}
}
},
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, messages: Array<Status>) => {

View File

@ -40,10 +40,13 @@ const mutations: MutationTree<MentionsState> = {
state.heading = value
},
[MUTATION_TYPES.APPEND_MENTIONS]: (state, update: Notification) => {
if (state.heading) {
state.mentions = [update].concat(state.mentions)
} else {
state.unreadMentions = [update].concat(state.unreadMentions)
// Reject duplicated status in timeline
if (!state.mentions.find(item => item.id === update.id) && !state.unreadMentions.find(item => item.id === update.id)) {
if (state.heading) {
state.mentions = [update].concat(state.mentions)
} else {
state.unreadMentions = [update].concat(state.unreadMentions)
}
}
},
[MUTATION_TYPES.UPDATE_MENTIONS]: (state, messages: Array<Notification>) => {

View File

@ -41,10 +41,16 @@ const mutations: MutationTree<NotificationsState> = {
state.heading = value
},
[MUTATION_TYPES.APPEND_NOTIFICATIONS]: (state, notification: Notification) => {
if (state.heading) {
state.notifications = [notification].concat(state.notifications)
} else {
state.unreadNotifications = [notification].concat(state.unreadNotifications)
// Reject duplicated status in timeline
if (
!state.notifications.find(item => item.id === notification.id) &&
!state.unreadNotifications.find(item => item.id === notification.id)
) {
if (state.heading) {
state.notifications = [notification].concat(state.notifications)
} else {
state.unreadNotifications = [notification].concat(state.unreadNotifications)
}
}
},
[MUTATION_TYPES.UPDATE_NOTIFICATIONS]: (state, notifications: Array<Notification>) => {

View File

@ -37,10 +37,13 @@ const mutations: MutationTree<PublicState> = {
state.heading = value
},
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
// Reject duplicated status in timeline
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
if (state.heading) {
state.timeline = [update].concat(state.timeline)
} else {
state.unreadTimeline = [update].concat(state.unreadTimeline)
}
}
},
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, messages: Array<Status>) => {