From 0e9b8be88caa8bb21891b2be5fe2eb1333aed345 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Tue, 2 Jul 2019 14:32:46 -0400
Subject: [PATCH 1/3] clear userId property of timeline by default in
clearTimeline action
---
src/components/timeline/timeline.js | 2 +-
src/modules/statuses.js | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js
index 9dafcbd8f4..b1c7edf802 100644
--- a/src/components/timeline/timeline.js
+++ b/src/components/timeline/timeline.js
@@ -86,7 +86,7 @@ const Timeline = {
if (this.newStatusCount === 0) return
if (this.timeline.flushMarker !== 0) {
- this.$store.commit('clearTimeline', { timeline: this.timelineName })
+ this.$store.commit('clearTimeline', { timeline: this.timelineName, excludeUserId: true })
this.$store.commit('queueFlush', { timeline: this.timelineName, id: 0 })
this.fetchOlderStatuses()
} else {
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index 9b11a13e03..e58a9b4c14 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -395,8 +395,9 @@ export const mutations = {
state[key] = value
})
},
- clearTimeline (state, { timeline }) {
- state.timelines[timeline] = emptyTl(state.timelines[timeline].userId)
+ clearTimeline (state, { timeline, excludeUserId = false }) {
+ const userId = excludeUserId ? state.timelines[timeline].userId : undefined
+ state.timelines[timeline] = emptyTl(userId)
},
clearNotifications (state) {
state.notifications = emptyNotifications()
From b70c2bfef756a398305c7933f0b6906be4432e4c Mon Sep 17 00:00:00 2001
From: taehoon
Date: Tue, 2 Jul 2019 14:43:01 -0400
Subject: [PATCH 2/3] make sure that user timelines are empty when opening
profile page
---
src/components/user_profile/user_profile.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js
index eab330e7dc..7eb4ed3ab0 100644
--- a/src/components/user_profile/user_profile.js
+++ b/src/components/user_profile/user_profile.js
@@ -31,6 +31,8 @@ const UserProfile = {
}
},
created () {
+ // Make sure that timelines used in this page are empty
+ this.cleanUp()
const routeParams = this.$route.params
this.load(routeParams.name || routeParams.id)
},
From d8e210df4d3f6e83c1fa0fc9b893b825cec45da4 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Tue, 2 Jul 2019 15:07:18 -0400
Subject: [PATCH 3/3] update test for clearTimeline action
---
test/unit/specs/modules/statuses.spec.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js
index 0bbcb25a3e..e4661e2a1d 100644
--- a/test/unit/specs/modules/statuses.spec.js
+++ b/test/unit/specs/modules/statuses.spec.js
@@ -258,11 +258,11 @@ describe('Statuses module', () => {
})
describe('clearTimeline', () => {
- it('keeps userId when clearing user timeline', () => {
+ it('keeps userId when clearing user timeline when excludeUserId param is true', () => {
const state = defaultState()
state.timelines.user.userId = 123
- mutations.clearTimeline(state, { timeline: 'user' })
+ mutations.clearTimeline(state, { timeline: 'user', excludeUserId: true })
expect(state.timelines.user.userId).to.eql(123)
})