remove blocked one from the results on real time
This commit is contained in:
parent
33467880ed
commit
9184435887
@ -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)
|
||||
|
@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="user-autosuggest" v-click-outside="onClickOutside">
|
||||
<input v-model="query" placeholder="Search whom you want to block" @click="onInputClick" class="user-autosuggest-input" />
|
||||
<div class="user-autosuggest-results" v-if="resultsVisible && results.length > 0">
|
||||
<BlockCard v-for="user in results" :key="user.id" :userId="user.id"/>
|
||||
<div class="user-autosuggest-results" v-if="resultsVisible && filtered.length > 0">
|
||||
<BlockCard v-for="userId in filtered" :key="userId" :userId="userId"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user