Change:persist last search term #142

This commit is contained in:
advplyr
2022-04-26 17:05:49 -05:00
parent d64dd63ea4
commit be885009ad
3 changed files with 20 additions and 3 deletions
+14 -1
View File
@@ -76,7 +76,11 @@ export default {
},
methods: {
async runSearch(value) {
if (this.isFetching && this.lastSearch === value) return
this.lastSearch = value
this.$store.commit('globals/setLastSearch', value)
if (!this.lastSearch) {
this.bookResults = []
this.podcastResults = []
@@ -89,6 +93,10 @@ export default {
console.error('Search error', error)
return []
})
if (value !== this.lastSearch) {
console.log(`runSearch: New search was made for ${this.lastSearch} - results are from ${value}`)
return
}
console.log('RESULTS', results)
this.isFetching = false
@@ -113,7 +121,12 @@ export default {
}
},
mounted() {
this.$nextTick(this.setFocus())
if (this.$store.state.globals.lastSearch) {
this.search = this.$store.state.globals.lastSearch
this.runSearch(this.search)
} else {
this.$nextTick(this.setFocus())
}
}
}
</script>