Add actual user search.
This commit is contained in:
parent
609ad40736
commit
c34eebff6c
8 changed files with 103 additions and 22 deletions
|
@ -7,25 +7,10 @@ const UserFinder = {
|
|||
}),
|
||||
methods: {
|
||||
findUser (username) {
|
||||
username = username[0] === '@' ? username.slice(1) : username
|
||||
this.loading = true
|
||||
this.$store.state.api.backendInteractor.externalProfile(username)
|
||||
.then((user) => {
|
||||
this.loading = false
|
||||
this.hidden = true
|
||||
if (!user.error) {
|
||||
this.$store.commit('addNewUsers', [user])
|
||||
this.$router.push({name: 'user-profile', params: {id: user.id}})
|
||||
} else {
|
||||
this.error = true
|
||||
}
|
||||
})
|
||||
this.$router.push({ name: 'user-search', query: { query: username } })
|
||||
},
|
||||
toggleHidden () {
|
||||
this.hidden = !this.hidden
|
||||
},
|
||||
dismissError () {
|
||||
this.error = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
<template>
|
||||
<span class="user-finder-container">
|
||||
<span class="alert error" v-if="error">
|
||||
<i class="icon-cancel user-finder-icon" @click="dismissError"/>
|
||||
{{$t('finder.error_fetching_user')}}
|
||||
</span>
|
||||
<i class="icon-spin4 user-finder-icon animate-spin-slow" v-if="loading" />
|
||||
<a href="#" v-if="hidden"><i class="icon-user-plus user-finder-icon" @click.prevent.stop="toggleHidden"/></a>
|
||||
<span v-else>
|
||||
|
|
33
src/components/user_search/user_search.js
Normal file
33
src/components/user_search/user_search.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import UserCard from '../user_card/user_card.vue'
|
||||
import userSearchApi from '../../services/new_api/user_search.js'
|
||||
const userSearch = {
|
||||
components: {
|
||||
UserCard
|
||||
},
|
||||
props: [
|
||||
'query'
|
||||
],
|
||||
data () {
|
||||
return {
|
||||
users: []
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.search(this.query)
|
||||
},
|
||||
watch: {
|
||||
query (newV) {
|
||||
this.search(newV)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
search (query) {
|
||||
userSearchApi.search({query, store: this.$store})
|
||||
.then((res) => {
|
||||
this.users = res
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default userSearch
|
12
src/components/user_search/user_search.vue
Normal file
12
src/components/user_search/user_search.vue
Normal file
|
@ -0,0 +1,12 @@
|
|||
<template>
|
||||
<div class="user-seach panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{{$t('nav.user_search')}}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<user-card v-for="user in users" :key="user.id" :user="user" :showFollows="true"></user-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script src="./user_search.js"></script>
|
Loading…
Add table
Add a link
Reference in a new issue