diff --git a/components/app/Appbar.vue b/components/app/Appbar.vue index 82d907d9..077f7a5a 100644 --- a/components/app/Appbar.vue +++ b/components/app/Appbar.vue @@ -18,7 +18,7 @@ -
+
cast
diff --git a/pages/search.vue b/pages/search.vue index 394d6ac6..6893f0ec 100644 --- a/pages/search.vue +++ b/pages/search.vue @@ -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()) + } } } diff --git a/store/globals.js b/store/globals.js index c2d286fc..6d4a2d11 100644 --- a/store/globals.js +++ b/store/globals.js @@ -2,7 +2,8 @@ export const state = () => ({ itemDownloads: [], bookshelfListView: false, series: null, - localMediaProgress: [] + localMediaProgress: [], + lastSearch: null }) export const getters = { @@ -82,5 +83,8 @@ export const mutations = { }, removeLocalMediaProgress(state, id) { state.localMediaProgress = state.localMediaProgress.filter(lmp => lmp.id != id) + }, + setLastSearch(state, val) { + state.lastSearch = val } } \ No newline at end of file