Refactor user search api, better api error response handling
This commit is contained in:
parent
2f87540612
commit
532b76eb64
7 changed files with 31 additions and 79 deletions
|
@ -35,15 +35,13 @@ const userSearch = {
|
|||
},
|
||||
search (query) {
|
||||
if (!query) {
|
||||
this.users = []
|
||||
return
|
||||
}
|
||||
this.loading = true
|
||||
this.userIds = []
|
||||
this.$store.dispatch('searchUsers', query)
|
||||
.then((res) => {
|
||||
this.loading = false
|
||||
this.userIds = map(res, 'id')
|
||||
})
|
||||
.then((res) => { this.userIds = map(res, 'id') })
|
||||
.finally(() => { this.loading = false })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import Autosuggest from '../autosuggest/autosuggest.vue'
|
|||
import Importer from '../importer/importer.vue'
|
||||
import Exporter from '../exporter/exporter.vue'
|
||||
import withSubscription from '../../hocs/with_subscription/with_subscription'
|
||||
import userSearchApi from '../../services/new_api/user_search.js'
|
||||
import Mfa from './mfa.vue'
|
||||
|
||||
const BlockList = withSubscription({
|
||||
|
@ -322,11 +321,8 @@ const UserSettings = {
|
|||
})
|
||||
},
|
||||
queryUserIds (query) {
|
||||
return userSearchApi.search({ query, store: this.$store })
|
||||
.then((users) => {
|
||||
this.$store.dispatch('addNewUsers', users)
|
||||
return map(users, 'id')
|
||||
})
|
||||
return this.$store.dispatch('searchUsers', query)
|
||||
.then((users) => map(users, 'id'))
|
||||
},
|
||||
blockUsers (ids) {
|
||||
return this.$store.dispatch('blockUsers', ids)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue