Add:Persist scroll position for bookshelves #196, Fix:Hide clear filter button for series and collections

This commit is contained in:
advplyr 2022-05-22 14:19:13 -05:00
parent 5d2da97dc5
commit 61b8ca1510
2 changed files with 28 additions and 1 deletions

View file

@ -25,6 +25,7 @@ export default {
mixins: [bookshelfCardsHelpers],
data() {
return {
routeFullPath: null,
entitiesPerShelf: 2,
bookshelfHeight: 0,
bookshelfWidth: 0,
@ -72,6 +73,7 @@ export default {
return this.page
},
hasFilter() {
if (this.page === 'series' || this.page === 'collections') return false
return this.filterBy !== 'all'
},
orderBy() {
@ -316,6 +318,15 @@ export default {
await this.loadPage(0)
var lastBookIndex = Math.min(this.totalEntities, this.shelvesPerPage * this.entitiesPerShelf)
this.mountEntites(0, lastBookIndex)
// Set last scroll position for this bookshelf page
if (this.$store.state.lastBookshelfScrollData[this.page] && window['bookshelf-wrapper']) {
const { path, scrollTop } = this.$store.state.lastBookshelfScrollData[this.page]
if (path === this.routeFullPath) {
// Exact path match with query so use scroll position
window['bookshelf-wrapper'].scrollTop = scrollTop
}
}
},
scroll(e) {
if (!e || !e.target) return
@ -358,6 +369,8 @@ export default {
if (newSearchParams !== this.currentSFQueryString || newSearchParams !== currentQueryString) {
let newurl = window.location.protocol + '//' + window.location.host + window.location.pathname + '?' + newSearchParams
window.history.replaceState({ path: newurl }, '', newurl)
this.routeFullPath = window.location.pathname + (window.location.search || '') // Update for saving scroll position
return true
}
@ -452,12 +465,22 @@ export default {
this.$socket.$off('items_added', this.libraryItemsAdded)
}
},
updated() {
this.routeFullPath = window.location.pathname + (window.location.search || '')
},
mounted() {
this.routeFullPath = window.location.pathname + (window.location.search || '')
this.init()
this.initListeners()
},
beforeDestroy() {
this.removeListeners()
// Set bookshelf scroll position for specific bookshelf page and query
if (window['bookshelf-wrapper']) {
this.$store.commit('setLastBookshelfScrollData', { scrollTop: window['bookshelf-wrapper'].scrollTop || 0, path: this.routeFullPath, name: this.page })
}
}
}
</script>

View file

@ -16,7 +16,8 @@ export const state = () => ({
showReader: false,
showSideDrawer: false,
isNetworkListenerInit: false,
serverSettings: null
serverSettings: null,
lastBookshelfScrollData: {}
})
export const getters = {
@ -54,6 +55,9 @@ export const actions = {
}
export const mutations = {
setLastBookshelfScrollData(state, { scrollTop, path, name }) {
state.lastBookshelfScrollData[name] = { scrollTop, path }
},
setPlayerItem(state, playbackSession) {
state.playerIsLocal = playbackSession ? playbackSession.playMethod == this.$constants.PlayMethod.LOCAL : false