From 91844358871e106add0822fc528b4deeaa32c2ec Mon Sep 17 00:00:00 2001
From: taehoon
Date: Tue, 2 Apr 2019 14:27:22 -0400
Subject: [PATCH] remove blocked one from the results on real time
---
.../user_autosuggest/user_autosuggest.js | 17 +++++++++++------
.../user_autosuggest/user_autosuggest.vue | 4 ++--
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/components/user_autosuggest/user_autosuggest.js b/src/components/user_autosuggest/user_autosuggest.js
index c8332e34..75798b7e 100644
--- a/src/components/user_autosuggest/user_autosuggest.js
+++ b/src/components/user_autosuggest/user_autosuggest.js
@@ -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)
diff --git a/src/components/user_autosuggest/user_autosuggest.vue b/src/components/user_autosuggest/user_autosuggest.vue
index 6253ca6b..930216a7 100644
--- a/src/components/user_autosuggest/user_autosuggest.vue
+++ b/src/components/user_autosuggest/user_autosuggest.vue
@@ -1,8 +1,8 @@