Update:Save last scroll position for item pages #717

This commit is contained in:
advplyr 2023-06-04 15:52:36 -05:00
parent 2643e98fc0
commit d207e88e18
2 changed files with 16 additions and 2 deletions

View file

@ -1,5 +1,5 @@
<template> <template>
<div class="w-full h-full px-3 pb-4 overflow-y-auto overflow-x-hidden relative bg-bg"> <div id="item-page" class="w-full h-full px-3 pb-4 overflow-y-auto overflow-x-hidden relative bg-bg">
<div class="fixed top-0 left-0 w-full h-full pointer-events-none p-px z-10"> <div class="fixed top-0 left-0 w-full h-full pointer-events-none p-px z-10">
<div class="w-full h-full" :style="{ backgroundColor: coverRgb }" /> <div class="w-full h-full" :style="{ backgroundColor: coverRgb }" />
<div class="w-full h-full absolute top-0 left-0" style="background: linear-gradient(169deg, rgba(0, 0, 0, 0.4) 0%, rgba(55, 56, 56, 1) 80%)" /> <div class="w-full h-full absolute top-0 left-0" style="background: linear-gradient(169deg, rgba(0, 0, 0, 0.4) 0%, rgba(55, 56, 56, 1) 80%)" />
@ -766,12 +766,22 @@ export default {
this.$eventBus.$on('new-local-library-item', this.newLocalLibraryItem) this.$eventBus.$on('new-local-library-item', this.newLocalLibraryItem)
this.$socket.$on('item_updated', this.itemUpdated) this.$socket.$on('item_updated', this.itemUpdated)
this.checkDescriptionClamped() this.checkDescriptionClamped()
// Set last scroll position if was set for this item
if (this.$store.state.lastItemScrollData.id === this.libraryItemId && window['item-page']) {
window['item-page'].scrollTop = this.$store.state.lastItemScrollData.scrollTop || 0
}
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener('resize', this.windowResized) window.removeEventListener('resize', this.windowResized)
this.$eventBus.$off('library-changed', this.libraryChanged) this.$eventBus.$off('library-changed', this.libraryChanged)
this.$eventBus.$off('new-local-library-item', this.newLocalLibraryItem) this.$eventBus.$off('new-local-library-item', this.newLocalLibraryItem)
this.$socket.$off('item_updated', this.itemUpdated) this.$socket.$off('item_updated', this.itemUpdated)
// Set scroll position
if (window['item-page']) {
this.$store.commit('setLastItemScrollData', { scrollTop: window['item-page'].scrollTop || 0, id: this.libraryItemId })
}
} }
} }
</script> </script>

View file

@ -22,7 +22,8 @@ export const state = () => ({
showSideDrawer: false, showSideDrawer: false,
isNetworkListenerInit: false, isNetworkListenerInit: false,
serverSettings: null, serverSettings: null,
lastBookshelfScrollData: {} lastBookshelfScrollData: {},
lastItemScrollData: {}
}) })
export const getters = { export const getters = {
@ -89,6 +90,9 @@ export const mutations = {
setLastBookshelfScrollData(state, { scrollTop, path, name }) { setLastBookshelfScrollData(state, { scrollTop, path, name }) {
state.lastBookshelfScrollData[name] = { scrollTop, path } state.lastBookshelfScrollData[name] = { scrollTop, path }
}, },
setLastItemScrollData(state, data) {
state.lastItemScrollData = data
},
setPlayerItem(state, playbackSession) { setPlayerItem(state, playbackSession) {
state.playerIsLocal = playbackSession ? playbackSession.playMethod == this.$constants.PlayMethod.LOCAL : false state.playerIsLocal = playbackSession ? playbackSession.playMethod == this.$constants.PlayMethod.LOCAL : false