diff options
| author | Maxim Filippov <colixer@gmail.com> | 2018-12-15 06:16:44 +0300 |
|---|---|---|
| committer | Maxim Filippov <colixer@gmail.com> | 2018-12-15 06:16:44 +0300 |
| commit | 828b1c78f9304d400a206a25f4f43999bc5908bc (patch) | |
| tree | 9c3f9d067384c5f2596890a8cbafe0d324ae3604 /src/components/user_profile/user_profile.js | |
| parent | 1341a7bb9cc14ecd0a1755cd2de1c09384a431c6 (diff) | |
Implement user_profile.spec.js
Diffstat (limited to 'src/components/user_profile/user_profile.js')
| -rw-r--r-- | src/components/user_profile/user_profile.js | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 8a32392a..95d797a2 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -3,19 +3,22 @@ import Timeline from '../timeline/timeline.vue' const UserProfile = { created () { + debugger this.$store.commit('clearTimeline', { timeline: 'user' }) - this.$store.dispatch('startFetching', ['user', this.userName]) + this.$store.dispatch('startFetching', ['user', this.fetchBy]) if (!this.user) { - this.$store.dispatch('fetchUser', this.userName) + this.$store.dispatch('fetchUser', this.fetchBy) } }, destroyed () { this.$store.dispatch('stopFetching', 'user') }, computed: { - timeline () { return this.$store.state.statuses.timelines.user }, + timeline () { + return this.$store.state.statuses.timelines.user + }, userId () { - return this.user.id + return this.$route.params.id }, userName () { return this.$route.params.name @@ -25,16 +28,33 @@ const UserProfile = { return this.timeline.statuses[0].user } else { return Object.values(this.$store.state.users.usersObject).filter(user => { - return user.screen_name === this.userName + return (this.isExternal ? user.id === this.userId : user.screen_name === this.userName) })[0] || false } + }, + fetchBy () { + return this.isExternal ? this.userId : this.userName + }, + isExternal () { + return this.$route.name === 'external-user-profile' } }, watch: { userName () { + if (this.isExternal) { + return + } this.$store.dispatch('stopFetching', 'user') this.$store.commit('clearTimeline', { timeline: 'user' }) this.$store.dispatch('startFetching', ['user', this.userName]) + }, + userId () { + if (!this.isExternal) { + return + } + this.$store.dispatch('stopFetching', 'user') + this.$store.commit('clearTimeline', { timeline: 'user' }) + this.$store.dispatch('startFetching', ['user', this.userId]) } }, components: { |
