search: add "is-loading" class to button

This commit is contained in:
Peter Stuifzand 2021-06-05 19:55:52 +02:00
parent 020e901474
commit c73efe8610
2 changed files with 12 additions and 6 deletions

View File

@ -35,7 +35,8 @@ export default {
props: ['is-open'], props: ['is-open'],
data() { data() {
return { return {
query: '' query: '',
loading: false
} }
}, },
mounted () { mounted () {
@ -60,7 +61,11 @@ export default {
}, },
methods: { methods: {
search () { search () {
this.loading = true
this.$store.dispatch('startQuery', this.query) this.$store.dispatch('startQuery', this.query)
.then(() => {
this.loading = false
})
}, },
close () { close () {
this.$store.dispatch('closeSearch') this.$store.dispatch('closeSearch')

View File

@ -265,15 +265,16 @@ export default new Vuex.Store({
if (state.channel.uid !== null) { if (state.channel.uid !== null) {
channel = state.channel.uid channel = state.channel.uid
} }
fetch(this.state.microsubEndpoint + '?action=search&channel='+channel+'&query='+query, { return fetch(this.state.microsubEndpoint + '?action=search&channel='+channel+'&query='+query, {
headers: { headers: {
'Authorization': 'Bearer ' + this.state.access_token 'Authorization': 'Bearer ' + this.state.access_token
}, },
method: 'POST' method: 'POST'
}).then(response => response.json()) })
.then(response => { .then(response => response.json())
commit('newSearchResults', response.items) .then(response => {
}) commit('newSearchResults', response.items)
})
}, },
createChannel(x, name) { createChannel(x, name) {
let url = this.state.microsubEndpoint + '?action=channels&name=' + encodeURIComponent(name) let url = this.state.microsubEndpoint + '?action=channels&name=' + encodeURIComponent(name)