aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/user_profile/user_profile.js53
1 files changed, 31 insertions, 22 deletions
diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js
index 4f920ae2..0f387f66 100644
--- a/src/components/user_profile/user_profile.js
+++ b/src/components/user_profile/user_profile.js
@@ -37,27 +37,7 @@ const UserProfile = {
},
created () {
if (!this.user.id) {
- let fetchPromise
- if (this.userId) {
- fetchPromise = this.$store.dispatch('fetchUser', this.userId)
- } else {
- fetchPromise = this.$store.dispatch('fetchUserByScreenName', this.userName)
- .then(userId => {
- this.fetchedUserId = userId
- })
- }
- fetchPromise
- .catch((reason) => {
- const errorMessage = get(reason, 'error.error')
- if (errorMessage === 'No user with such user_id') { // Known error
- this.error = this.$t('user_profile.profile_does_not_exist')
- } else if (errorMessage) {
- this.error = errorMessage
- } else {
- this.error = this.$t('user_profile.profile_loading_error')
- }
- })
- .then(() => this.startUp())
+ this.fetchUserId()
}
},
destroyed () {
@@ -112,8 +92,30 @@ const UserProfile = {
this.$store.dispatch('startFetching', { timeline: 'favorites', userId: this.userId })
}
},
+ fetchUserId () {
+ let fetchPromise
+ if (this.userId && !this.$route.params.name) {
+ fetchPromise = this.$store.dispatch('fetchUser', this.userId)
+ } else {
+ fetchPromise = this.$store.dispatch('fetchUserByScreenName', this.userName)
+ .then(userId => {
+ this.fetchedUserId = userId
+ })
+ }
+ fetchPromise
+ .catch((reason) => {
+ const errorMessage = get(reason, 'error.error')
+ if (errorMessage === 'No user with such user_id') { // Known error
+ this.error = this.$t('user_profile.profile_does_not_exist')
+ } else if (errorMessage) {
+ this.error = errorMessage
+ } else {
+ this.error = this.$t('user_profile.profile_loading_error')
+ }
+ })
+ .then(() => this.startUp())
+ },
startUp () {
- this.$store.dispatch('fetchUserRelationship', this.userId)
this.$store.dispatch('startFetching', { timeline: 'user', userId: this.userId })
this.$store.dispatch('startFetching', { timeline: 'media', userId: this.userId })
this.startFetchFavorites()
@@ -134,6 +136,13 @@ const UserProfile = {
this.startUp()
}
},
+ userName (newVal, oldVal) {
+ if (this.$route.params.name) {
+ this.fetchUserId()
+ this.cleanUp()
+ this.startUp()
+ }
+ },
$route () {
this.$refs.tabSwitcher.activateTab(0)()
}