aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHJ <spam@hjkos.com>2018-12-31 01:57:22 +0000
committerHJ <spam@hjkos.com>2018-12-31 01:57:22 +0000
commit7aa42c01eb5f05c2e3ed71fc52be6a30e45802bf (patch)
tree2071ec16f17bc714817575ad7699707f92cb664b /src
parent1316ed43a5d203294cb7a41bb19d5fca98f5cea1 (diff)
parentfb8f774383f122d3254748f7f97ab6c562a5c339 (diff)
Merge branch 'fix/profile-with-no-statuses-not-loading' into 'develop'
Fix profiles without statuses not loading See merge request pleroma/pleroma-fe!445
Diffstat (limited to 'src')
-rw-r--r--src/components/user_profile/user_profile.js16
-rw-r--r--src/modules/users.js8
2 files changed, 19 insertions, 5 deletions
diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js
index 77bb1835..2ca09817 100644
--- a/src/components/user_profile/user_profile.js
+++ b/src/components/user_profile/user_profile.js
@@ -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
diff --git a/src/modules/users.js b/src/modules/users.js
index 2f05ed3f..adbd37dd 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -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 })