remember last query until refresh

This commit is contained in:
Bui 2022-02-26 00:47:09 +00:00
parent d85d48bc1f
commit 1ef724c4c1
2 changed files with 11 additions and 0 deletions

View File

@ -258,6 +258,10 @@ class Loader{
db = new IDB("taiko", "store") db = new IDB("taiko", "store")
plugins = new Plugins() plugins = new Plugins()
if(localStorage.getItem("lastSearchQuery")){
localStorage.removeItem("lastSearchQuery")
}
Promise.all(this.promises).then(() => { Promise.all(this.promises).then(() => {
if(this.error){ if(this.error){
return return

View File

@ -2798,6 +2798,12 @@ class SongSelect{
setTimeout(() => { setTimeout(() => {
this.search.input.focus() this.search.input.focus()
}, 10) }, 10)
var lastQuery = localStorage.getItem("lastSearchQuery")
if(lastQuery){
this.search.input.value = lastQuery
this.search.input.dispatchEvent(new Event('input', {value: lastQuery}))
}
} }
removeSearch(byUser=false){ removeSearch(byUser=false){
@ -2987,6 +2993,7 @@ class SongSelect{
} }
var new_results = this.performSearch(text) var new_results = this.performSearch(text)
localStorage.setItem("lastSearchQuery", text)
if (new_results.length === 0) { if (new_results.length === 0) {
this.setSearchTip(strings.search.noResults, true) this.setSearchTip(strings.search.noResults, true)