From 6e5a1a108561d3a7b4102f823b9986b7e0d19ac1 Mon Sep 17 00:00:00 2001 From: Preston Date: Fri, 19 Jun 2020 15:46:01 -0400 Subject: [PATCH] Add toggle for search suggestions --- .../general-settings/general-settings.js | 4 ++++ .../general-settings/general-settings.vue | 5 +++++ src/renderer/components/top-nav/top-nav.js | 8 +++++++- src/renderer/store/modules/settings.js | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/general-settings/general-settings.js b/src/renderer/components/general-settings/general-settings.js index 7116bb77..884f6bd3 100644 --- a/src/renderer/components/general-settings/general-settings.js +++ b/src/renderer/components/general-settings/general-settings.js @@ -552,6 +552,9 @@ export default Vue.extend({ invidiousInstance: function () { return this.$store.getters.getInvidiousInstance }, + enableSearchSuggestions: function () { + return this.$store.getters.getEnableSearchSuggestions + }, backendFallback: function () { return this.$store.getters.getBackendFallback }, @@ -616,6 +619,7 @@ export default Vue.extend({ }, ...mapActions([ + 'updateEnableSearchSuggestions', 'updateBackendFallback', 'updateCheckForUpdates', 'updateBarColor', diff --git a/src/renderer/components/general-settings/general-settings.vue b/src/renderer/components/general-settings/general-settings.vue index 91832530..3e1c7928 100644 --- a/src/renderer/components/general-settings/general-settings.vue +++ b/src/renderer/components/general-settings/general-settings.vue @@ -12,6 +12,11 @@ :default-value="backendFallback" @change="updateBackendFallback" /> + { + return state.enableSearchSuggestions + }, + getBackendPreference: () => { return state.backendPreference }, @@ -169,6 +174,9 @@ const actions = { case 'checkForUpdates': commit('setCheckForUpdates', result.value) break + case 'enableSearchSuggestions': + commit('setEnableSearchSuggestions', result.value) + break case 'backendPreference': commit('setBackendPreference', result.value) break @@ -255,6 +263,14 @@ const actions = { }) }, + updateEnableSearchSuggestions ({ commit }, enableSearchSuggestions) { + settingsDb.update({ _id: 'enableSearchSuggestions' }, { _id: 'enableSearchSuggestions', value: enableSearchSuggestions }, { upsert: true }, (err, numReplaced) => { + if (!err) { + commit('setEnableSearchSuggestions', enableSearchSuggestions) + } + }) + }, + updateBackendPreference ({ commit }, backendPreference) { settingsDb.update({ _id: 'backendPreference' }, { _id: 'backendPreference', value: backendPreference }, { upsert: true }, (err, numReplaced) => { if (!err) { @@ -440,6 +456,9 @@ const mutations = { setBarColor (state, barColor) { state.barColor = barColor }, + setEnableSearchSuggestions (state, enableSearchSuggestions) { + state.enableSearchSuggestions = enableSearchSuggestions + }, setRememberHistory (state, rememberHistory) { state.rememberHistory = rememberHistory },