mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-12-14 06:10:28 +05:30
Ensure most recent search is on top.
This commit is contained in:
parent
09582cb502
commit
f920a1aae8
@ -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 New Issue
Block a user