mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-04 01:54:33 +02:00
Change:persist last search term #142
This commit is contained in:
parent
d64dd63ea4
commit
be885009ad
3 changed files with 20 additions and 3 deletions
|
@ -18,7 +18,7 @@
|
|||
<widgets-download-progress-indicator />
|
||||
|
||||
<!-- Must be connected to a server to cast, only supports media items on server -->
|
||||
<div v-show="isCastAvailable && user" class="mx-2 cursor-pointer mt-1">
|
||||
<div v-show="isCastAvailable && user" class="mx-2 cursor-pointer mt-1.5">
|
||||
<span class="material-icons" :class="isCasting ? 'text-success' : ''" style="font-size: 1.6rem" @click="castClick">cast</span>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue