From c73efe86101057151999eb68cfdc9c527d3acccb Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sat, 5 Jun 2021 19:55:52 +0200 Subject: [PATCH] search: add "is-loading" class to button --- src/components/SearchPopup.vue | 7 ++++++- src/store.js | 11 ++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/SearchPopup.vue b/src/components/SearchPopup.vue index 37d48a5..e90be36 100644 --- a/src/components/SearchPopup.vue +++ b/src/components/SearchPopup.vue @@ -35,7 +35,8 @@ export default { props: ['is-open'], data() { return { - query: '' + query: '', + loading: false } }, mounted () { @@ -60,7 +61,11 @@ export default { }, methods: { search () { + this.loading = true this.$store.dispatch('startQuery', this.query) + .then(() => { + this.loading = false + }) }, close () { this.$store.dispatch('closeSearch') diff --git a/src/store.js b/src/store.js index 3b3de5a..63bb9a6 100644 --- a/src/store.js +++ b/src/store.js @@ -265,15 +265,16 @@ export default new Vuex.Store({ if (state.channel.uid !== null) { 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: { 'Authorization': 'Bearer ' + this.state.access_token }, method: 'POST' - }).then(response => response.json()) - .then(response => { - commit('newSearchResults', response.items) - }) + }) + .then(response => response.json()) + .then(response => { + commit('newSearchResults', response.items) + }) }, createChannel(x, name) { let url = this.state.microsubEndpoint + '?action=channels&name=' + encodeURIComponent(name)