remove blocked one from the results on real time

This commit is contained in:
taehoon 2019-04-02 14:27:22 -04:00
parent 33467880ed
commit 9184435887
2 changed files with 13 additions and 8 deletions

View file

@ -1,4 +1,5 @@
import reject from 'lodash/reject'
import map from 'lodash/map'
import BlockCard from '../block_card/block_card.vue'
import userSearchApi from '../../services/new_api/user_search.js'
@ -16,6 +17,14 @@ export default {
resultsVisible: false
}
},
computed: {
filtered () {
return reject(this.results, (userId) => {
const user = this.$store.getters.findUser(userId)
return !user || user.statusnet_blocking || user.id === this.$store.state.users.currentUser.id
})
}
},
watch: {
query (val) {
this.fetchResults(val)
@ -29,12 +38,8 @@ export default {
if (query) {
userSearchApi.search({query, store: this.$store})
.then((users) => {
const filteredUsers = reject(users, (user) => {
return user.statusnet_blocking || user.id === this.$store.state.users.currentUser.id
})
this.$store.dispatch('addNewUsers', filteredUsers)
this.results = filteredUsers
this.resultsVisible = true
this.$store.dispatch('addNewUsers', users)
this.results = map(users, 'id')
})
}
}, debounceMilliseconds)