From 2e8cb46c57081354e98a1f51a63be4a59eeca183 Mon Sep 17 00:00:00 2001 From: mikiher Date: Wed, 19 Feb 2025 21:04:07 +0200 Subject: [PATCH 1/2] Resort title-sorted bookshelf after title change --- client/components/app/LazyBookshelf.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/components/app/LazyBookshelf.vue b/client/components/app/LazyBookshelf.vue index 22ab731d..ab6d54a2 100644 --- a/client/components/app/LazyBookshelf.vue +++ b/client/components/app/LazyBookshelf.vue @@ -547,6 +547,15 @@ export default { if (this.entityName === 'items' || this.entityName === 'series-books') { var indexOf = this.entities.findIndex((ent) => ent && ent.id === libraryItem.id) if (indexOf >= 0) { + if (this.entityName === 'items' && this.orderBy === 'media.metadata.title') { + const curTitle = this.entities[indexOf].media.metadata?.title + const newTitle = libraryItem.media.metadata?.title + if (curTitle != newTitle) { + console.log('Title changed. Re-sorting...') + this.resetEntities() + return + } + } this.entities[indexOf] = libraryItem if (this.entityComponentRefs[indexOf]) { this.entityComponentRefs[indexOf].setEntity(libraryItem) From f04ef320aae0071172255adad607b6e53f3e0fb8 Mon Sep 17 00:00:00 2001 From: advplyr Date: Wed, 19 Feb 2025 17:12:19 -0600 Subject: [PATCH 2/2] Restore scroll position on title change re-sort --- client/components/app/LazyBookshelf.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/client/components/app/LazyBookshelf.vue b/client/components/app/LazyBookshelf.vue index ab6d54a2..2144b899 100644 --- a/client/components/app/LazyBookshelf.vue +++ b/client/components/app/LazyBookshelf.vue @@ -419,7 +419,7 @@ export default { this.postScrollTimeout = setTimeout(this.postScroll, 500) }, - async resetEntities() { + async resetEntities(scrollPositionToRestore) { if (this.isFetchingEntities) { this.pendingReset = true return @@ -437,6 +437,12 @@ export default { await this.loadPage(0) var lastBookIndex = Math.min(this.totalEntities, this.shelvesPerPage * this.entitiesPerShelf) this.mountEntities(0, lastBookIndex) + + if (scrollPositionToRestore) { + if (window.bookshelf) { + window.bookshelf.scrollTop = scrollPositionToRestore + } + } }, async rebuild() { this.initSizeData() @@ -444,9 +450,8 @@ export default { var lastBookIndex = Math.min(this.totalEntities, this.booksPerFetch) this.destroyEntityComponents() await this.loadPage(0) - var bookshelfEl = document.getElementById('bookshelf') - if (bookshelfEl) { - bookshelfEl.scrollTop = 0 + if (window.bookshelf) { + window.bookshelf.scrollTop = 0 } this.mountEntities(0, lastBookIndex) }, @@ -552,7 +557,7 @@ export default { const newTitle = libraryItem.media.metadata?.title if (curTitle != newTitle) { console.log('Title changed. Re-sorting...') - this.resetEntities() + this.resetEntities(this.currScrollTop) return } }