diff --git a/src/components/SearchPopup.vue b/src/components/SearchPopup.vue
index bdf226b..f870797 100644
--- a/src/components/SearchPopup.vue
+++ b/src/components/SearchPopup.vue
@@ -16,7 +16,14 @@
-
+
+
+
@@ -38,7 +45,8 @@ export default {
return {
query: '',
loading: false,
- error: ''
+ error: '',
+ searchChannel: 'global'
}
},
mounted () {
@@ -65,7 +73,7 @@ export default {
search () {
this.loading = true
this.error = ''
- this.$store.dispatch('startQuery', this.query)
+ this.$store.dispatch('startQuery', {query: this.query, channel: this.searchChannel})
.then(result => {
this.loading = false
if (result.error) {
diff --git a/src/store.js b/src/store.js
index 0cc408e..3953afd 100644
--- a/src/store.js
+++ b/src/store.js
@@ -268,14 +268,22 @@ export default new Vuex.Store({
commit('setSearchPopupState', false)
},
startQuery({state, commit}, query) {
- let channel = 'global'
- if (state.channel !== null && state.channel.uid !== null && state.channel.uid !== 'home') {
- channel = state.channel.uid
+ let channel
+ if (query.channel) {
+ if (query.channel === 'global') {
+ channel = 'global'
+ } else if (query.channel === 'channel') {
+ if (state.channel !== null && state.channel.uid !== null) {
+ channel = state.channel.uid
+ }
+ } else {
+ channel = 'global'
+ }
}
const url = new URL(this.state.microsubEndpoint)
url.searchParams.set('action', 'search')
url.searchParams.set('channel', channel)
- url.searchParams.set('query', query)
+ url.searchParams.set('query', query.query)
return fetch(url.toString(), {
headers: {
'Authorization': 'Bearer ' + this.state.access_token
diff --git a/src/views/Home.vue b/src/views/Home.vue
index 1a6a434..576ef62 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -3,7 +3,7 @@
-
+
@@ -80,6 +80,9 @@
channel() {
return this.$store.state.channel
},
+ channels() {
+ return this.$store.state.channels
+ },
channelsClass () {
return {
'channels-open': this.channelsVisible,