Restore scroll position on title change re-sort

This commit is contained in:
advplyr 2025-02-19 17:12:19 -06:00
parent 2e8cb46c57
commit f04ef320aa

View File

@ -419,7 +419,7 @@ export default {
this.postScrollTimeout = setTimeout(this.postScroll, 500) this.postScrollTimeout = setTimeout(this.postScroll, 500)
}, },
async resetEntities() { async resetEntities(scrollPositionToRestore) {
if (this.isFetchingEntities) { if (this.isFetchingEntities) {
this.pendingReset = true this.pendingReset = true
return return
@ -437,6 +437,12 @@ export default {
await this.loadPage(0) await this.loadPage(0)
var lastBookIndex = Math.min(this.totalEntities, this.shelvesPerPage * this.entitiesPerShelf) var lastBookIndex = Math.min(this.totalEntities, this.shelvesPerPage * this.entitiesPerShelf)
this.mountEntities(0, lastBookIndex) this.mountEntities(0, lastBookIndex)
if (scrollPositionToRestore) {
if (window.bookshelf) {
window.bookshelf.scrollTop = scrollPositionToRestore
}
}
}, },
async rebuild() { async rebuild() {
this.initSizeData() this.initSizeData()
@ -444,9 +450,8 @@ export default {
var lastBookIndex = Math.min(this.totalEntities, this.booksPerFetch) var lastBookIndex = Math.min(this.totalEntities, this.booksPerFetch)
this.destroyEntityComponents() this.destroyEntityComponents()
await this.loadPage(0) await this.loadPage(0)
var bookshelfEl = document.getElementById('bookshelf') if (window.bookshelf) {
if (bookshelfEl) { window.bookshelf.scrollTop = 0
bookshelfEl.scrollTop = 0
} }
this.mountEntities(0, lastBookIndex) this.mountEntities(0, lastBookIndex)
}, },
@ -552,7 +557,7 @@ export default {
const newTitle = libraryItem.media.metadata?.title const newTitle = libraryItem.media.metadata?.title
if (curTitle != newTitle) { if (curTitle != newTitle) {
console.log('Title changed. Re-sorting...') console.log('Title changed. Re-sorting...')
this.resetEntities() this.resetEntities(this.currScrollTop)
return return
} }
} }