mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-12-14 14:20:28 +05:30
commit
d65adfffc7
@ -101,7 +101,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<SearchSuggestions
|
<SearchSuggestions
|
||||||
v-show="searchText && suggestionsVisible"
|
v-show="(searchText || showSearchHistory) && suggestionsVisible"
|
||||||
ref="searchSuggestions"
|
ref="searchSuggestions"
|
||||||
:search-text="searchText"
|
:search-text="searchText"
|
||||||
@searchchange="onSearchTextChange"
|
@searchchange="onSearchTextChange"
|
||||||
@ -137,6 +137,9 @@ export default {
|
|||||||
shouldShowTrending(_this) {
|
shouldShowTrending(_this) {
|
||||||
return _this.getPreferenceString("homepage", "trending") != "trending";
|
return _this.getPreferenceString("homepage", "trending") != "trending";
|
||||||
},
|
},
|
||||||
|
showSearchHistory() {
|
||||||
|
return localStorage.getItem("searchHistory") && localStorage.getItem("search_history");
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// focus on search bar when Ctrl+k is pressed
|
// focus on search bar when Ctrl+k is pressed
|
||||||
@ -163,6 +166,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onInputFocus() {
|
onInputFocus() {
|
||||||
|
if (this.showSearchHistory) this.$refs.searchSuggestions.refreshSuggestions();
|
||||||
this.suggestionsVisible = true;
|
this.suggestionsVisible = true;
|
||||||
},
|
},
|
||||||
onInputBlur() {
|
onInputBlur() {
|
||||||
|
@ -96,6 +96,16 @@
|
|||||||
@change="onChange($event)"
|
@change="onChange($event)"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="pref" for="chkStoreSearchHistory">
|
||||||
|
<strong v-t="'actions.store_search_history'" />
|
||||||
|
<input
|
||||||
|
id="chkStoreSearchHistory"
|
||||||
|
v-model="searchHistory"
|
||||||
|
class="checkbox"
|
||||||
|
type="checkbox"
|
||||||
|
@change="onChange($event)"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
<label class="pref" for="chkStoreWatchHistory">
|
<label class="pref" for="chkStoreWatchHistory">
|
||||||
<strong v-t="'actions.store_watch_history'" />
|
<strong v-t="'actions.store_watch_history'" />
|
||||||
<input
|
<input
|
||||||
@ -355,6 +365,7 @@ export default {
|
|||||||
minimizeDescription: false,
|
minimizeDescription: false,
|
||||||
minimizeRecommendations: false,
|
minimizeRecommendations: false,
|
||||||
watchHistory: false,
|
watchHistory: false,
|
||||||
|
searchHistory: false,
|
||||||
selectedLanguage: "en",
|
selectedLanguage: "en",
|
||||||
languages: [
|
languages: [
|
||||||
{ code: "ar", name: "Arabic" },
|
{ code: "ar", name: "Arabic" },
|
||||||
@ -489,6 +500,7 @@ export default {
|
|||||||
this.minimizeDescription = this.getPreferenceBoolean("minimizeDescription", false);
|
this.minimizeDescription = this.getPreferenceBoolean("minimizeDescription", false);
|
||||||
this.minimizeRecommendations = this.getPreferenceBoolean("minimizeRecommendations", false);
|
this.minimizeRecommendations = this.getPreferenceBoolean("minimizeRecommendations", false);
|
||||||
this.watchHistory = this.getPreferenceBoolean("watchHistory", false);
|
this.watchHistory = this.getPreferenceBoolean("watchHistory", false);
|
||||||
|
this.searchHistory = this.getPreferenceBoolean("searchHistory", false);
|
||||||
this.selectedLanguage = this.getPreferenceString("hl", await this.defaultLangage);
|
this.selectedLanguage = this.getPreferenceString("hl", await this.defaultLangage);
|
||||||
this.enabledCodecs = this.getPreferenceString("enabledCodecs", "vp9,avc").split(",");
|
this.enabledCodecs = this.getPreferenceString("enabledCodecs", "vp9,avc").split(",");
|
||||||
this.disableLBRY = this.getPreferenceBoolean("disableLBRY", false);
|
this.disableLBRY = this.getPreferenceBoolean("disableLBRY", false);
|
||||||
@ -546,6 +558,8 @@ export default {
|
|||||||
localStorage.setItem("minimizeDescription", this.minimizeDescription);
|
localStorage.setItem("minimizeDescription", this.minimizeDescription);
|
||||||
localStorage.setItem("minimizeRecommendations", this.minimizeRecommendations);
|
localStorage.setItem("minimizeRecommendations", this.minimizeRecommendations);
|
||||||
localStorage.setItem("watchHistory", this.watchHistory);
|
localStorage.setItem("watchHistory", this.watchHistory);
|
||||||
|
localStorage.setItem("searchHistory", this.searchHistory);
|
||||||
|
if (!this.searchHistory) localStorage.removeItem("search_history");
|
||||||
localStorage.setItem("hl", this.selectedLanguage);
|
localStorage.setItem("hl", this.selectedLanguage);
|
||||||
localStorage.setItem("enabledCodecs", this.enabledCodecs.join(","));
|
localStorage.setItem("enabledCodecs", this.enabledCodecs.join(","));
|
||||||
localStorage.setItem("disableLBRY", this.disableLBRY);
|
localStorage.setItem("disableLBRY", this.disableLBRY);
|
||||||
|
@ -77,6 +77,7 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
if (this.handleRedirect()) return;
|
if (this.handleRedirect()) return;
|
||||||
this.updateResults();
|
this.updateResults();
|
||||||
|
this.saveQueryToHistory();
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
this.handleRedirect();
|
this.handleRedirect();
|
||||||
@ -138,6 +139,19 @@ export default {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
saveQueryToHistory() {
|
||||||
|
if (!this.getPreferenceBoolean("searchHistory", false)) return;
|
||||||
|
const query = this.$route.query.search_query;
|
||||||
|
if (!query) return;
|
||||||
|
const searchHistory = JSON.parse(localStorage.getItem("search_history")) ?? [];
|
||||||
|
if (searchHistory.includes(query)) {
|
||||||
|
const index = searchHistory.indexOf(query);
|
||||||
|
searchHistory.splice(index, 1);
|
||||||
|
}
|
||||||
|
searchHistory.unshift(query);
|
||||||
|
if (searchHistory.length > 10) searchHistory.shift();
|
||||||
|
localStorage.setItem("search_history", JSON.stringify(searchHistory));
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -47,11 +47,16 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async refreshSuggestions() {
|
async refreshSuggestions() {
|
||||||
this.searchSuggestions = (
|
if (!this.searchText) {
|
||||||
await this.fetchJson(this.apiUrl() + "/opensearch/suggestions", {
|
if (this.getPreferenceBoolean("searchHistory", false))
|
||||||
query: this.searchText,
|
this.searchSuggestions = JSON.parse(localStorage.getItem("search_history")) ?? [];
|
||||||
})
|
} else {
|
||||||
)?.[1];
|
this.searchSuggestions = (
|
||||||
|
await this.fetchJson(this.apiUrl() + "/opensearch/suggestions", {
|
||||||
|
query: this.searchText,
|
||||||
|
})
|
||||||
|
)?.[1];
|
||||||
|
}
|
||||||
this.searchSuggestions.unshift(this.searchText);
|
this.searchSuggestions.unshift(this.searchText);
|
||||||
this.setSelected(0);
|
this.setSelected(0);
|
||||||
},
|
},
|
||||||
|
@ -106,7 +106,8 @@
|
|||||||
"follow_link": "Follow link",
|
"follow_link": "Follow link",
|
||||||
"copy_link": "Copy link",
|
"copy_link": "Copy link",
|
||||||
"time_code": "Time code (in seconds)",
|
"time_code": "Time code (in seconds)",
|
||||||
"show_chapters": "Chapters"
|
"show_chapters": "Chapters",
|
||||||
|
"store_search_history": "Store Search history"
|
||||||
},
|
},
|
||||||
"comment": {
|
"comment": {
|
||||||
"pinned_by": "Pinned by",
|
"pinned_by": "Pinned by",
|
||||||
|
Loading…
Reference in New Issue
Block a user