mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Ensure most recent search is on top.
This commit is contained in:
parent
09582cb502
commit
f920a1aae8
1 changed files with 5 additions and 1 deletions
|
@ -144,7 +144,11 @@ export default {
|
|||
const query = this.$route.query.search_query;
|
||||
if (!query) return;
|
||||
const searchHistory = JSON.parse(localStorage.getItem("search_history")) ?? [];
|
||||
if (!searchHistory.includes(query)) searchHistory.push(query);
|
||||
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));
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue