improve code quality

This commit is contained in:
Brenden Bice 2019-04-02 11:04:39 -04:00
parent d19bee0b66
commit 4ab2ddb03c
3 changed files with 8 additions and 20 deletions

View File

@ -1,7 +1,7 @@
<template>
<ul class="avatars" :class="{ 'transparent-avatar': slicedAvatars.length == 10 }">
<li class="avatars__item" v-for="(avatar, index) in slicedAvatars" :key="index">
<UserAvatar :src="avatar.src" class="avatars__img" />
<li class="avatars__item" v-for="avatar in slicedAvatars" :key="avatar.id">
<UserAvatar :src="avatar.avatar_static" class="avatars__img" />
</li>
</ul>
</template>

View File

@ -153,22 +153,10 @@ const conversation = {
}
},
fetchFavouritedByUsers (id) {
this.$store.state.api.backendInteractor.fetchFavouritedByUsers({id}).then((response) => {
const favoritedByUsers = response.map(item => ({
src: item.avatar_static,
name: item.display_name
}))
this.$store.dispatch('addFavoritedByUsers', { favoritedByUsers, id })
})
this.$store.dispatch('fetchFavouritedByUsers', { id })
},
fetchRebloggedByUsers (id) {
this.$store.state.api.backendInteractor.fetchRebloggedByUsers({id}).then((response) => {
const rebloggedByUsers = response.map(item => ({
src: item.avatar_static,
name: item.display_name
}))
this.$store.dispatch('addRebloggedByUsers', { rebloggedByUsers, id })
})
this.$store.dispatch('fetchRebloggedByUsers', { id })
}
}
}

View File

@ -537,11 +537,11 @@ const statuses = {
credentials: rootState.users.currentUser.credentials
})
},
addFavoritedByUsers ({ rootState, commit }, { favoritedByUsers, id }) {
commit('addFavoritedByUsers', { favoritedByUsers, id })
fetchFavouritedByUsers ({ rootState, commit }, { id }) {
rootState.api.backendInteractor.fetchFavouritedByUsers({id}).then((favoritedByUsers) => commit('addFavoritedByUsers', { favoritedByUsers, id }))
},
addRebloggedByUsers ({ rootState, commit }, { rebloggedByUsers, id }) {
commit('addRebloggedByUsers', { rebloggedByUsers, id })
fetchRebloggedByUsers ({ rootState, commit }, { id }) {
rootState.api.backendInteractor.fetchRebloggedByUsers({id}).then((rebloggedByUsers) => commit('addRebloggedByUsers', { rebloggedByUsers, id }))
}
},
mutations