From 6f4c90a2cff80844c552fbb1fecf5e2bc6cd187a Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 13 Nov 2019 22:53:38 +0900
Subject: [PATCH 1/8] refs #1096 Reject duplicated status when append statuses
in Home
---
.../store/TimelineSpace/Contents/Home.spec.ts | 97 +++++++++++++------
.../store/TimelineSpace/Contents/Home.ts | 11 ++-
2 files changed, 76 insertions(+), 32 deletions(-)
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts
index 84969ad3..800c9ec4 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts
@@ -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])
+ })
})
})
})
diff --git a/src/renderer/store/TimelineSpace/Contents/Home.ts b/src/renderer/store/TimelineSpace/Contents/Home.ts
index f2326d7d..5518ab54 100644
--- a/src/renderer/store/TimelineSpace/Contents/Home.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Home.ts
@@ -46,10 +46,13 @@ const mutations: MutationTree = {
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) => {
From 414280d28434df79ad89251c45946d431df43bab Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 13 Nov 2019 23:23:41 +0900
Subject: [PATCH 2/8] refs #1096 Reject duplicated status when append statuses
in DirectMessages
---
.../Contents/DirectMessages.spec.ts | 137 ++++++++++++++----
.../TimelineSpace/Contents/DirectMessages.ts | 11 +-
2 files changed, 113 insertions(+), 35 deletions(-)
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts
index d976ecaa..fa0c5249 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts
@@ -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([])
+ })
+ })
+ })
+ })
})
})
diff --git a/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts b/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts
index fa6d437f..3a51aa75 100644
--- a/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts
+++ b/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts
@@ -40,10 +40,13 @@ const mutations: MutationTree = {
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) => {
From 46a86f4778952a464d430df72f4bb62a8e373849 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 13 Nov 2019 23:27:01 +0900
Subject: [PATCH 3/8] refs #1096 Reject duplicated status when append statuses
in Local
---
.../TimelineSpace/Contents/Local.spec.ts | 136 ++++++++++++++----
.../store/TimelineSpace/Contents/Local.ts | 11 +-
2 files changed, 112 insertions(+), 35 deletions(-)
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts
index 10dc8fa9..899eb185 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts
@@ -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([])
+ })
+ })
+ })
+ })
})
})
diff --git a/src/renderer/store/TimelineSpace/Contents/Local.ts b/src/renderer/store/TimelineSpace/Contents/Local.ts
index d773feb0..3e988789 100644
--- a/src/renderer/store/TimelineSpace/Contents/Local.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Local.ts
@@ -37,10 +37,13 @@ const mutations: MutationTree = {
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) => {
From a68b34c2527b00e7c2adb566a99564c2d6cbe1dc Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 13 Nov 2019 23:29:37 +0900
Subject: [PATCH 4/8] refs #1096 Reject duplicated status when append statuses
in Public
---
.../TimelineSpace/Contents/Public.spec.ts | 137 ++++++++++++++----
.../store/TimelineSpace/Contents/Public.ts | 11 +-
2 files changed, 113 insertions(+), 35 deletions(-)
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts
index 33a3b19b..183cbb4e 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts
@@ -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([])
+ })
+ })
+ })
+ })
})
})
diff --git a/src/renderer/store/TimelineSpace/Contents/Public.ts b/src/renderer/store/TimelineSpace/Contents/Public.ts
index db6ece74..92931056 100644
--- a/src/renderer/store/TimelineSpace/Contents/Public.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Public.ts
@@ -37,10 +37,13 @@ const mutations: MutationTree = {
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) => {
From 542eaf29594e14c28345366198b188f326cf8aaa Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 13 Nov 2019 23:35:00 +0900
Subject: [PATCH 5/8] refs #1096 Reject duplicated status when append statuses
in Mentions
---
.../TimelineSpace/Contents/Mentions.spec.ts | 87 ++++++++++++++-----
.../store/TimelineSpace/Contents/Mentions.ts | 11 ++-
2 files changed, 70 insertions(+), 28 deletions(-)
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts
index 57abf3c2..eff364f1 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts
@@ -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])
+ })
})
})
})
diff --git a/src/renderer/store/TimelineSpace/Contents/Mentions.ts b/src/renderer/store/TimelineSpace/Contents/Mentions.ts
index ccc8f796..58ace721 100644
--- a/src/renderer/store/TimelineSpace/Contents/Mentions.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Mentions.ts
@@ -40,10 +40,13 @@ const mutations: MutationTree = {
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) => {
From 9cdeba0df58f1be988c2a8fbcc2de6edff1ec76c Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 13 Nov 2019 23:42:50 +0900
Subject: [PATCH 6/8] refs #1096 Reject duplicated status when append statuses
in Notifications
---
.../Contents/Notifications.spec.ts | 73 +++++++++++++++++++
.../TimelineSpace/Contents/Notifications.ts | 14 +++-
2 files changed, 83 insertions(+), 4 deletions(-)
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts
index 6a7531ab..99f54e36 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts
@@ -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])
+ })
+ })
+ })
+ })
})
})
diff --git a/src/renderer/store/TimelineSpace/Contents/Notifications.ts b/src/renderer/store/TimelineSpace/Contents/Notifications.ts
index 1225b95e..2e245bbd 100644
--- a/src/renderer/store/TimelineSpace/Contents/Notifications.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Notifications.ts
@@ -41,10 +41,16 @@ const mutations: MutationTree = {
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) => {
From b48a877f5dc587a6b7ba09324a294dd5b81fab74 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 13 Nov 2019 23:49:55 +0900
Subject: [PATCH 7/8] refs #1096 Reject duplicated status when append statuses
in Lists
---
.../TimelineSpace/Contents/Lists/Show.spec.ts | 137 ++++++++++++++----
.../TimelineSpace/Contents/Lists/Show.ts | 11 +-
2 files changed, 113 insertions(+), 35 deletions(-)
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
index 5781a43d..bae785cb 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
@@ -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([])
+ })
+ })
+ })
+ })
})
})
diff --git a/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts b/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts
index cb938e70..78a8adbc 100644
--- a/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts
@@ -39,10 +39,13 @@ const mutations: MutationTree = {
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) => {
From 961f90d6068a59bc01dce4287170c3c1ec6496ab Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 13 Nov 2019 23:50:02 +0900
Subject: [PATCH 8/8] refs #1096 Reject duplicated status when append statuses
in Hashtag
---
.../Contents/Hashtag/Tag.spec.ts | 137 ++++++++++++++----
.../TimelineSpace/Contents/Hashtag/Tag.ts | 11 +-
2 files changed, 113 insertions(+), 35 deletions(-)
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
index e5151fbc..e05edaed 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
@@ -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([])
+ })
+ })
+ })
+ })
})
})
diff --git a/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts b/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts
index e732351f..9bb43811 100644
--- a/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts
@@ -39,10 +39,13 @@ const mutations: MutationTree = {
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) => {