add search history

This commit is contained in:
Bnyro
2022-09-11 20:01:58 +02:00
committed by Kavin
parent 7308e19f6c
commit cdfa850081
5 changed files with 39 additions and 7 deletions

View File

@@ -101,7 +101,7 @@
/>
</div>
<SearchSuggestions
v-show="searchText && suggestionsVisible"
v-show="(searchText || showSearchHistory) && suggestionsVisible"
ref="searchSuggestions"
:search-text="searchText"
@searchchange="onSearchTextChange"
@@ -137,6 +137,9 @@ export default {
shouldShowTrending(_this) {
return _this.getPreferenceString("homepage", "trending") != "trending";
},
showSearchHistory() {
return localStorage.getItem("searchHistory") && localStorage.getItem("search_history");
},
},
methods: {
// focus on search bar when Ctrl+k is pressed
@@ -163,6 +166,7 @@ export default {
}
},
onInputFocus() {
if (this.showSearchHistory) this.$refs.searchSuggestions.refreshSuggestions();
this.suggestionsVisible = true;
},
onInputBlur() {