+
+
+
+
+
-
-
-
-
-
Date: Fri, 19 Jul 2019 22:46:11 -0400
Subject: [PATCH 04/12] put two loops in one parent
---
src/components/timeline/timeline.vue | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue
index 9990f20a77..4337ac36e8 100644
--- a/src/components/timeline/timeline.vue
+++ b/src/components/timeline/timeline.vue
@@ -31,15 +31,13 @@
-
-
Date: Fri, 19 Jul 2019 22:47:40 -0400
Subject: [PATCH 05/12] update prop syntax
---
src/components/user_profile/user_profile.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue
index f4b284e2d2..fc745d1a6a 100644
--- a/src/components/user_profile/user_profile.vue
+++ b/src/components/user_profile/user_profile.vue
@@ -20,7 +20,7 @@
:embedded="true"
:title="$t('user_profile.timeline_title')"
:timeline="timeline"
- :timeline-name="'user'"
+ timeline-name="user"
:user-id="userId"
:pinned-status-ids="user.pinnedStatuseIds"
/>
From 876c6de8066d9ac708bb0cd8e4d4c5e60f9502a6 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Fri, 19 Jul 2019 22:49:29 -0400
Subject: [PATCH 06/12] fix typos
---
src/components/user_profile/user_profile.vue | 2 +-
src/modules/users.js | 6 +++---
src/services/entity_normalizer/entity_normalizer.service.js | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue
index fc745d1a6a..e862440eb2 100644
--- a/src/components/user_profile/user_profile.vue
+++ b/src/components/user_profile/user_profile.vue
@@ -22,7 +22,7 @@
:timeline="timeline"
timeline-name="user"
:user-id="userId"
- :pinned-status-ids="user.pinnedStatuseIds"
+ :pinned-status-ids="user.pinnedStatusIds"
/>
{
output.statuses_count = data.statuses_count
output.friendIds = []
output.followerIds = []
- output.pinnedStatuseIds = []
+ output.pinnedStatusIds = []
if (data.pleroma) {
output.follow_request_count = data.pleroma.follow_request_count
From 0f8ace483649c1da66a1270373a3b95683ff9a0b Mon Sep 17 00:00:00 2001
From: taehoon
Date: Sat, 20 Jul 2019 16:54:30 -0400
Subject: [PATCH 07/12] update status eliminating logic
---
src/components/timeline/timeline.js | 14 ++++++++++----
src/components/timeline/timeline.vue | 16 +++++++++-------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js
index 7c8a761a80..b141359145 100644
--- a/src/components/timeline/timeline.js
+++ b/src/components/timeline/timeline.js
@@ -41,12 +41,18 @@ const Timeline = {
footer: ['timeline-footer'].concat(!this.embedded ? ['panel-footer'] : [])
}
},
- statuses () {
+ // id map of statuses which need to be hidden in the main list due to pinning logic
+ excludedStatusIdsObject () {
+ const result = {}
if (this.pinnedStatusIds && this.pinnedStatusIds.length > 0) {
- return this.timeline.visibleStatuses && this.timeline.visibleStatuses.filter(status => !this.pinnedStatusIds.includes(status.id))
- } else {
- return this.timeline.visibleStatuses
+ for (let status of this.timeline.visibleStatuses) {
+ if (this.pinnedStatusIds.indexOf(status.id) === -1) {
+ break
+ }
+ result[status.id] = true
+ }
}
+ return result
}
},
components: {
diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue
index 4337ac36e8..0cb4b3ef8d 100644
--- a/src/components/timeline/timeline.vue
+++ b/src/components/timeline/timeline.vue
@@ -38,13 +38,15 @@
:show-pinned="true"
/>
-
+
+
+
From 53c9517a4aeae1158a95e3b9c6d6d89e3a7e0ee9 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Wed, 24 Jul 2019 22:42:06 -0400
Subject: [PATCH 08/12] use array.includes instead of array.indexOf
---
src/components/timeline/timeline.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js
index b141359145..a5c6418b2d 100644
--- a/src/components/timeline/timeline.js
+++ b/src/components/timeline/timeline.js
@@ -46,7 +46,7 @@ const Timeline = {
const result = {}
if (this.pinnedStatusIds && this.pinnedStatusIds.length > 0) {
for (let status of this.timeline.visibleStatuses) {
- if (this.pinnedStatusIds.indexOf(status.id) === -1) {
+ if (!this.pinnedStatusIds.includes(status.id)) {
break
}
result[status.id] = true
From 65ef03931661561db0791ee7d560292dda6b7d48 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Thu, 25 Jul 2019 08:03:41 -0400
Subject: [PATCH 09/12] add unit test for elimination logic
---
src/components/timeline/timeline.js | 28 +++++++++++++--------
test/unit/specs/components/timeline.spec.js | 17 +++++++++++++
2 files changed, 34 insertions(+), 11 deletions(-)
create mode 100644 test/unit/specs/components/timeline.spec.js
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js
index a5c6418b2d..aac3869f59 100644
--- a/src/components/timeline/timeline.js
+++ b/src/components/timeline/timeline.js
@@ -1,7 +1,20 @@
import Status from '../status/status.vue'
import timelineFetcher from '../../services/timeline_fetcher/timeline_fetcher.service.js'
import Conversation from '../conversation/conversation.vue'
-import { throttle } from 'lodash'
+import { throttle, keyBy } from 'lodash'
+
+export const getExcludedStatusIdsByPinning = (statuses, pinnedStatusIds) => {
+ const ids = []
+ if (pinnedStatusIds && pinnedStatusIds.length > 0) {
+ for (let status of statuses) {
+ if (!pinnedStatusIds.includes(status.id)) {
+ break
+ }
+ ids.push(status.id)
+ }
+ }
+ return ids
+}
const Timeline = {
props: [
@@ -43,16 +56,9 @@ const Timeline = {
},
// id map of statuses which need to be hidden in the main list due to pinning logic
excludedStatusIdsObject () {
- const result = {}
- if (this.pinnedStatusIds && this.pinnedStatusIds.length > 0) {
- for (let status of this.timeline.visibleStatuses) {
- if (!this.pinnedStatusIds.includes(status.id)) {
- break
- }
- result[status.id] = true
- }
- }
- return result
+ const ids = getExcludedStatusIdsByPinning(this.timeline.visibleStatuses, this.pinnedStatusIds)
+ // Convert id array to object
+ return keyBy(ids, id => id)
}
},
components: {
diff --git a/test/unit/specs/components/timeline.spec.js b/test/unit/specs/components/timeline.spec.js
new file mode 100644
index 0000000000..b13d3e2075
--- /dev/null
+++ b/test/unit/specs/components/timeline.spec.js
@@ -0,0 +1,17 @@
+import { getExcludedStatusIdsByPinning } from 'src/components/timeline/timeline.js'
+import { difference } from 'lodash'
+
+describe('Timeline', () => {
+ describe('getExcludedStatusIdsByPinning', () => {
+ it('should not return unpinned status ids', () => {
+ const statuses = [
+ { id: 1 },
+ { id: 2 },
+ { id: 3 },
+ { id: 4 }
+ ]
+ const pinnedStatusIds = [1, 3]
+ expect(difference(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds), pinnedStatusIds)).to.eql([])
+ })
+ })
+})
\ No newline at end of file
From a443a5203e19eb43cdff76b1e3e6502a5b917bc9 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Thu, 25 Jul 2019 14:17:48 -0400
Subject: [PATCH 10/12] add more unit tests for elimination logic
---
test/unit/specs/components/timeline.spec.js | 31 +++++++++++++++------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/test/unit/specs/components/timeline.spec.js b/test/unit/specs/components/timeline.spec.js
index b13d3e2075..48796cd398 100644
--- a/test/unit/specs/components/timeline.spec.js
+++ b/test/unit/specs/components/timeline.spec.js
@@ -3,15 +3,28 @@ import { difference } from 'lodash'
describe('Timeline', () => {
describe('getExcludedStatusIdsByPinning', () => {
- it('should not return unpinned status ids', () => {
- const statuses = [
- { id: 1 },
- { id: 2 },
- { id: 3 },
- { id: 4 }
- ]
- const pinnedStatusIds = [1, 3]
+ const mockStatuses = (ids) => ids.map(id => ({ id }))
+
+ it('should not return any unpinned status ids', () => {
+ const statuses = mockStatuses([1, 2, 3, 4])
+ const pinnedStatusIds = [1, 3, 5]
expect(difference(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds), pinnedStatusIds)).to.eql([])
})
+
+ it('should not return any status ids not listed in the given statuses', () => {
+ const statusIds = [1, 2, 3, 4]
+ const statuses = mockStatuses(statusIds)
+ const pinnedStatusIds = [1, 3, 5]
+ expect(difference(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds), statusIds)).to.eql([])
+ })
+
+ it('should return ids of pinned statuses not posted before any unpinned status', () => {
+ const pinnedStatusIdSet1 = ['PINNED1', 'PINNED2']
+ const pinnedStatusIdSet2 = ['PINNED3', 'PINNED4']
+ const pinnedStatusIds = [...pinnedStatusIdSet1, ...pinnedStatusIdSet2]
+ const statusIds = [...pinnedStatusIdSet1, 'UNPINNED1', ...pinnedStatusIdSet2]
+ const statuses = mockStatuses(statusIds)
+ expect(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds)).to.eql(pinnedStatusIdSet1)
+ })
})
-})
\ No newline at end of file
+})
From d785ed5a05b3123d95e8627a0f82f0f9cddec33f Mon Sep 17 00:00:00 2001
From: taehoon
Date: Thu, 25 Jul 2019 23:34:56 -0400
Subject: [PATCH 11/12] rewrite unit tests
---
test/unit/specs/components/timeline.spec.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/test/unit/specs/components/timeline.spec.js b/test/unit/specs/components/timeline.spec.js
index 48796cd398..c1fdd0dd9b 100644
--- a/test/unit/specs/components/timeline.spec.js
+++ b/test/unit/specs/components/timeline.spec.js
@@ -1,5 +1,4 @@
import { getExcludedStatusIdsByPinning } from 'src/components/timeline/timeline.js'
-import { difference } from 'lodash'
describe('Timeline', () => {
describe('getExcludedStatusIdsByPinning', () => {
@@ -8,14 +7,14 @@ describe('Timeline', () => {
it('should not return any unpinned status ids', () => {
const statuses = mockStatuses([1, 2, 3, 4])
const pinnedStatusIds = [1, 3, 5]
- expect(difference(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds), pinnedStatusIds)).to.eql([])
+ expect(pinnedStatusIds).to.include.members(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds))
})
it('should not return any status ids not listed in the given statuses', () => {
const statusIds = [1, 2, 3, 4]
const statuses = mockStatuses(statusIds)
const pinnedStatusIds = [1, 3, 5]
- expect(difference(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds), statusIds)).to.eql([])
+ expect(statusIds).to.include.members(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds))
})
it('should return ids of pinned statuses not posted before any unpinned status', () => {
From 18a41e785ed85531f032a0aa1b6bfdce5a892fa9 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Sun, 28 Jul 2019 16:55:34 -0400
Subject: [PATCH 12/12] update unit test
---
test/unit/specs/components/timeline.spec.js | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/test/unit/specs/components/timeline.spec.js b/test/unit/specs/components/timeline.spec.js
index c1fdd0dd9b..0c8674a844 100644
--- a/test/unit/specs/components/timeline.spec.js
+++ b/test/unit/specs/components/timeline.spec.js
@@ -4,17 +4,15 @@ describe('Timeline', () => {
describe('getExcludedStatusIdsByPinning', () => {
const mockStatuses = (ids) => ids.map(id => ({ id }))
- it('should not return any unpinned status ids', () => {
- const statuses = mockStatuses([1, 2, 3, 4])
- const pinnedStatusIds = [1, 3, 5]
- expect(pinnedStatusIds).to.include.members(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds))
- })
-
- it('should not return any status ids not listed in the given statuses', () => {
+ it('should return only members of both pinnedStatusIds and ids of the given statuses', () => {
const statusIds = [1, 2, 3, 4]
const statuses = mockStatuses(statusIds)
const pinnedStatusIds = [1, 3, 5]
- expect(statusIds).to.include.members(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds))
+ const result = getExcludedStatusIdsByPinning(statuses, pinnedStatusIds)
+ result.forEach(item => {
+ expect(item).to.be.oneOf(statusIds)
+ expect(item).to.be.oneOf(pinnedStatusIds)
+ })
})
it('should return ids of pinned statuses not posted before any unpinned status', () => {