From 0b45f63f3578a3fdf8d937b1b1fc71b6d37f97c9 Mon Sep 17 00:00:00 2001 From: Ruben GM <2044827+rubengarciam@users.noreply.github.com> Date: Wed, 10 Sep 2025 13:42:48 +1000 Subject: [PATCH] consider series name when sorting books (#1123) --- .../components/book-browser/book-browser.component.ts | 10 +++++++++- booklore-ui/src/app/book/service/sort.service.ts | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts b/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts index 7a712172f..42baa0663 100644 --- a/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts +++ b/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts @@ -673,7 +673,15 @@ export class BookBrowserComponent implements OnInit { const forceExpandSeries = this.shouldForceExpandSeries(); return this.headerFilter.filter(bookState).pipe( switchMap(filtered => this.sideBarFilter.filter(filtered)), - switchMap(filtered => this.seriesCollapseFilter.filter(filtered, forceExpandSeries)) + switchMap(filtered => this.seriesCollapseFilter.filter(filtered, forceExpandSeries)), + map(filtered => + (filtered.loaded && !filtered.error) + ? ({ + ...filtered, + books: this.sortService.applySort(filtered.books || [], this.bookSorter.selectedSort!) + }) + : filtered + ) ); } diff --git a/booklore-ui/src/app/book/service/sort.service.ts b/booklore-ui/src/app/book/service/sort.service.ts index 7f120aeb6..6fe9a7ca9 100644 --- a/booklore-ui/src/app/book/service/sort.service.ts +++ b/booklore-ui/src/app/book/service/sort.service.ts @@ -8,7 +8,8 @@ import {SortDirection, SortOption} from "../model/sort.model"; export class SortService { private readonly fieldExtractors: Record any> = { - title: (book) => book.metadata?.title?.toLowerCase() || null, + title: (book) => (book.seriesCount ? (book.metadata?.seriesName?.toLowerCase() || null) : null) + ?? (book.metadata?.title?.toLowerCase() || null), titleSeries: (book) => { const title = book.metadata?.title?.toLowerCase() || ''; const series = book.metadata?.seriesName?.toLowerCase();