Option to disable search suggestions

This commit is contained in:
Bnyro 2023-06-13 10:24:29 +02:00
parent 06c5601e75
commit bf1ecc4c25
3 changed files with 19 additions and 2 deletions

View file

@ -136,6 +136,16 @@
@change="onChange($event)"
/>
</label>
<label class="pref" for="chkShowSearchSuggestions">
<strong v-t="'actions.show_search_suggestions'" />
<input
id="chkShowSearchSuggestions"
v-model="searchSuggestions"
class="checkbox"
type="checkbox"
@change="onChange($event)"
/>
</label>
<label class="pref" for="chkStoreSearchHistory">
<strong v-t="'actions.store_search_history'" />
<input
@ -387,6 +397,7 @@ export default {
minimizeRecommendations: false,
minimizeChapters: false,
showWatchOnYouTube: false,
searchSuggestions: true,
watchHistory: false,
searchHistory: false,
hideWatched: false,
@ -504,6 +515,7 @@ export default {
this.minimizeRecommendations = this.getPreferenceBoolean("minimizeRecommendations", false);
this.minimizeChapters = this.getPreferenceBoolean("minimizeChapters", false);
this.showWatchOnYouTube = this.getPreferenceBoolean("showWatchOnYouTube", false);
this.searchSuggestions = this.getPreferenceBoolean("searchSuggestions", true);
this.watchHistory = this.getPreferenceBoolean("watchHistory", false);
this.searchHistory = this.getPreferenceBoolean("searchHistory", false);
this.selectedLanguage = this.getPreferenceString("hl", await this.defaultLanguage);
@ -560,6 +572,7 @@ export default {
localStorage.setItem("minimizeRecommendations", this.minimizeRecommendations);
localStorage.setItem("minimizeChapters", this.minimizeChapters);
localStorage.setItem("showWatchOnYouTube", this.showWatchOnYouTube);
localStorage.setItem("searchSuggestions", this.searchSuggestions);
localStorage.setItem("watchHistory", this.watchHistory);
localStorage.setItem("searchHistory", this.searchHistory);
if (!this.searchHistory) localStorage.removeItem("search_history");

View file

@ -50,13 +50,16 @@ export default {
if (!this.searchText) {
if (this.getPreferenceBoolean("searchHistory", false))
this.searchSuggestions = JSON.parse(localStorage.getItem("search_history")) ?? [];
} else {
} else if (this.getPreferenceBoolean("searchSuggestions", true)) {
this.searchSuggestions =
(
await this.fetchJson(this.apiUrl() + "/opensearch/suggestions", {
query: this.searchText,
})
)?.[1] ?? [];
} else {
this.searchSuggestions = [];
return;
}
this.searchSuggestions.unshift(this.searchText);
this.setSelected(0);

View file

@ -137,7 +137,8 @@
"create_group": "Create group",
"group_name": "Group name",
"cancel": "Cancel",
"okay": "Okay"
"okay": "Okay",
"show_search_suggestions": "Show search suggestions"
},
"comment": {
"pinned_by": "Pinned by {author}",