Fix profiles without statuses not loading
This commit is contained in:
parent
1316ed43a5
commit
fb8f774383
4 changed files with 100 additions and 126 deletions
|
@ -6,7 +6,7 @@ const UserProfile = {
|
|||
created () {
|
||||
this.$store.commit('clearTimeline', { timeline: 'user' })
|
||||
this.$store.dispatch('startFetching', ['user', this.fetchBy])
|
||||
if (!this.user) {
|
||||
if (!this.user.id) {
|
||||
this.$store.dispatch('fetchUser', this.fetchBy)
|
||||
}
|
||||
},
|
||||
|
@ -29,14 +29,20 @@ const UserProfile = {
|
|||
followers () {
|
||||
return this.user.followers
|
||||
},
|
||||
userInStore () {
|
||||
if (this.isExternal) {
|
||||
return this.$store.getters.userById(this.userId)
|
||||
}
|
||||
return this.$store.getters.userByName(this.userName)
|
||||
},
|
||||
user () {
|
||||
if (this.timeline.statuses[0]) {
|
||||
return this.timeline.statuses[0].user
|
||||
} else {
|
||||
return Object.values(this.$store.state.users.usersObject).filter(user => {
|
||||
return (this.isExternal ? user.id === this.userId : user.screen_name === this.userName)
|
||||
})[0] || {}
|
||||
}
|
||||
if (this.userInStore) {
|
||||
return this.userInStore
|
||||
}
|
||||
return {}
|
||||
},
|
||||
fetchBy () {
|
||||
return this.isExternal ? this.userId : this.userName
|
||||
|
|
|
@ -86,6 +86,13 @@ export const mutations = {
|
|||
}
|
||||
}
|
||||
|
||||
export const getters = {
|
||||
userById: state => id =>
|
||||
state.users.find(user => user.id === id),
|
||||
userByName: state => name =>
|
||||
state.users.find(user => user.screen_name === name)
|
||||
}
|
||||
|
||||
export const defaultState = {
|
||||
loggingIn: false,
|
||||
lastLoginName: false,
|
||||
|
@ -99,6 +106,7 @@ export const defaultState = {
|
|||
const users = {
|
||||
state: defaultState,
|
||||
mutations,
|
||||
getters,
|
||||
actions: {
|
||||
fetchUser (store, id) {
|
||||
store.rootState.api.backendInteractor.fetchUser({ id })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue