1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-14 14:20:28 +05:30

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

View File

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

View File

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