refer searched user objects from the global user rep

This commit is contained in:
taehoon 2019-04-11 15:46:44 -04:00
parent c8f967d5c0
commit f2f3fa81d8
2 changed files with 19 additions and 4 deletions

View file

@ -1,5 +1,6 @@
import FollowCard from '../follow_card/follow_card.vue'
import userSearchApi from '../../services/new_api/user_search.js'
import map from 'lodash/map'
const userSearch = {
components: {
FollowCard
@ -10,10 +11,15 @@ const userSearch = {
data () {
return {
username: '',
users: [],
userIds: [],
loading: false
}
},
computed: {
users () {
return this.userIds.map(userId => this.$store.getters.findUser(userId))
}
},
mounted () {
this.search(this.query)
},
@ -33,10 +39,10 @@ const userSearch = {
return
}
this.loading = true
userSearchApi.search({query, store: this.$store})
this.$store.dispatch('searchUsers', query)
.then((res) => {
this.loading = false
this.users = res
this.userIds = map(res, 'id')
})
}
}