From 20e73bd1080c0f05b48ad2b6ea5c7f5dcbec9d5e Mon Sep 17 00:00:00 2001
From: ACX <8075870+acx10@users.noreply.github.com>
Date: Tue, 10 Feb 2026 21:41:46 -0700
Subject: [PATCH] feat(filter): add audiobook narrator filter and sort option
---
.../book-browser/book-filter/book-filter.component.html | 2 +-
.../book-browser/book-filter/book-filter.component.ts | 2 --
.../components/book-browser/book-filter/book-filter.config.ts | 4 ++++
.../book/components/book-browser/filters/sidebar-filter.ts | 2 ++
.../book/components/book-browser/sorting/BookSorter.ts | 1 +
booklore-ui/src/app/features/book/service/sort.service.ts | 1 +
.../src/app/features/settings/user-management/user.service.ts | 2 ++
.../view-preferences/view-preferences.component.ts | 1 +
booklore-ui/src/i18n/en/settings-view.json | 1 +
booklore-ui/src/i18n/es/settings-view.json | 1 +
10 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.html b/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.html
index a4327ec52..2e2b4b9d6 100644
--- a/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.html
+++ b/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.html
@@ -9,7 +9,7 @@
optionValue="value"
class="filter-mode-select"
allowEmpty="false"
- class="h-8">
+ >
diff --git a/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.ts b/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.ts
index 96b1d08ac..477a94659 100644
--- a/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.ts
+++ b/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.ts
@@ -118,7 +118,6 @@ export class BookFilterComponent implements OnInit, OnDestroy {
this.updateExpandedPanels();
}
- // Template Helpers
getVirtualScrollHeight = (itemCount: number): number => Math.min(itemCount * 28, 440);
trackByFilterType = (_: number, type: FilterType): string => type;
@@ -167,7 +166,6 @@ export class BookFilterComponent implements OnInit, OnDestroy {
}
private updateVisibleFilterTypes(): void {
- // Filter and order filterTypes based on user's visible filter preferences
this.visibleFilterTypes = this._visibleFilters.filter(
vf => this.filterTypes.includes(vf as FilterType)
) as FilterType[];
diff --git a/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.config.ts b/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.config.ts
index 3000564ad..8c6e50d20 100644
--- a/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.config.ts
+++ b/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.config.ts
@@ -21,6 +21,7 @@ export type FilterType =
| 'shelfStatus' | 'tag' | 'publishedDate' | 'fileSize' | 'amazonRating'
| 'goodreadsRating' | 'hardcoverRating' | 'language' | 'pageCount' | 'mood'
| 'ageRating' | 'contentRating'
+ | 'narrator'
| 'comicCharacter' | 'comicTeam' | 'comicLocation' | 'comicCreator';
export type SortMode = 'count' | 'sortIndex';
@@ -158,6 +159,7 @@ export const FILTER_LABELS: Readonly> = {
mood: 'Mood',
ageRating: 'Age Rating',
contentRating: 'Content Rating',
+ narrator: 'Narrator',
comicCharacter: 'Comic Character',
comicTeam: 'Comic Team',
comicLocation: 'Comic Location',
@@ -236,6 +238,7 @@ export const FILTER_EXTRACTORS: Readonly,
const label = CONTENT_RATING_LABELS[rating] ?? rating;
return [{id: rating, name: label}];
},
+ narrator: (book) => extractSingleString(book.metadata?.narrator),
comicCharacter: (book) => extractStringsAsFilters(book.metadata?.comicMetadata?.characters),
comicTeam: (book) => extractStringsAsFilters(book.metadata?.comicMetadata?.teams),
comicLocation: (book) => extractStringsAsFilters(book.metadata?.comicMetadata?.locations),
@@ -288,6 +291,7 @@ export const FILTER_CONFIGS: Readonly, Omi
mood: {label: 'Mood', sortMode: 'count'},
ageRating: {label: 'Age Rating', sortMode: 'sortIndex', isNumericId: true},
contentRating: {label: 'Content Rating', sortMode: 'count'},
+ narrator: {label: 'Narrator', sortMode: 'count'},
comicCharacter: {label: 'Comic Character', sortMode: 'count'},
comicTeam: {label: 'Comic Team', sortMode: 'count'},
comicLocation: {label: 'Comic Location', sortMode: 'count'},
diff --git a/booklore-ui/src/app/features/book/components/book-browser/filters/sidebar-filter.ts b/booklore-ui/src/app/features/book/components/book-browser/filters/sidebar-filter.ts
index 56e271704..b2d9cd0d1 100644
--- a/booklore-ui/src/app/features/book/components/book-browser/filters/sidebar-filter.ts
+++ b/booklore-ui/src/app/features/book/components/book-browser/filters/sidebar-filter.ts
@@ -128,6 +128,8 @@ export function doesBookMatchFilter(
});
case 'contentRating':
return filterValues.includes(book.metadata?.contentRating);
+ case 'narrator':
+ return filterValues.includes(book.metadata?.narrator);
case 'comicCharacter':
return mode === 'or'
? filterValues.some(val => book.metadata?.comicMetadata?.characters?.includes(val as string))
diff --git a/booklore-ui/src/app/features/book/components/book-browser/sorting/BookSorter.ts b/booklore-ui/src/app/features/book/components/book-browser/sorting/BookSorter.ts
index c7bb75c2c..9c16e56d8 100644
--- a/booklore-ui/src/app/features/book/components/book-browser/sorting/BookSorter.ts
+++ b/booklore-ui/src/app/features/book/components/book-browser/sorting/BookSorter.ts
@@ -30,6 +30,7 @@ export class BookSorter {
{label: 'Hardcover Rating', field: 'hardcoverRating', direction: SortDirection.ASCENDING},
{label: 'Hardcover #', field: 'hardcoverReviewCount', direction: SortDirection.ASCENDING},
{label: 'Ranobedb Rating', field: 'ranobedbRating', direction: SortDirection.ASCENDING},
+ {label: 'Narrator', field: 'narrator', direction: SortDirection.ASCENDING},
{label: 'Pages', field: 'pageCount', direction: SortDirection.ASCENDING},
{label: 'Random', field: 'random', direction: SortDirection.ASCENDING},
];
diff --git a/booklore-ui/src/app/features/book/service/sort.service.ts b/booklore-ui/src/app/features/book/service/sort.service.ts
index a2f97d0b0..9aea14c63 100644
--- a/booklore-ui/src/app/features/book/service/sort.service.ts
+++ b/booklore-ui/src/app/features/book/service/sort.service.ts
@@ -111,6 +111,7 @@ export class SortService {
?? book.koboProgress?.percentage
?? null,
bookType: (book) => book.primaryFile?.bookType || null,
+ narrator: (book) => book.metadata?.narrator?.toLowerCase() || null,
};
applySort(books: Book[], selectedSort: SortOption | null): Book[] {
diff --git a/booklore-ui/src/app/features/settings/user-management/user.service.ts b/booklore-ui/src/app/features/settings/user-management/user.service.ts
index e92d919da..dfee9dde7 100644
--- a/booklore-ui/src/app/features/settings/user-management/user.service.ts
+++ b/booklore-ui/src/app/features/settings/user-management/user.service.ts
@@ -194,6 +194,7 @@ export type VisibleFilterType =
| 'shelfStatus' | 'tag' | 'publishedDate' | 'fileSize' | 'amazonRating'
| 'goodreadsRating' | 'hardcoverRating' | 'language' | 'pageCount' | 'mood'
| 'ageRating' | 'contentRating'
+ | 'narrator'
| 'comicCharacter' | 'comicTeam' | 'comicLocation' | 'comicCreator';
export const DEFAULT_VISIBLE_FILTERS: VisibleFilterType[] = [
@@ -225,6 +226,7 @@ export const ALL_FILTER_OPTIONS: { label: string; value: VisibleFilterType }[] =
{label: 'Amazon Rating', value: 'amazonRating'},
{label: 'Goodreads Rating', value: 'goodreadsRating'},
{label: 'Hardcover Rating', value: 'hardcoverRating'},
+ {label: 'Narrator', value: 'narrator'},
{label: 'Comic Character', value: 'comicCharacter'},
{label: 'Comic Team', value: 'comicTeam'},
{label: 'Comic Location', value: 'comicLocation'},
diff --git a/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts b/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts
index 790b9867d..1971c9e3e 100644
--- a/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts
+++ b/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts
@@ -70,6 +70,7 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
{label: 'Hardcover Rating', field: 'hardcoverRating', translationKey: 'sortHardcoverRating'},
{label: 'Hardcover #', field: 'hardcoverReviewCount', translationKey: 'sortHardcoverCount'},
{label: 'Ranobedb Rating', field: 'ranobedbRating', translationKey: 'sortRanobedbRating'},
+ {label: 'Narrator', field: 'narrator', translationKey: 'sortNarrator'},
{label: 'Pages', field: 'pageCount', translationKey: 'sortPages'},
{label: 'Random', field: 'random', translationKey: 'sortRandom'},
];
diff --git a/booklore-ui/src/i18n/en/settings-view.json b/booklore-ui/src/i18n/en/settings-view.json
index 6252b63e9..a40e9ba95 100644
--- a/booklore-ui/src/i18n/en/settings-view.json
+++ b/booklore-ui/src/i18n/en/settings-view.json
@@ -51,6 +51,7 @@
"sortDateFinished": "Date Finished",
"sortReadingProgress": "Reading Progress",
"sortBookType": "Book Type",
+ "sortNarrator": "Narrator",
"sortPages": "Pages",
"sortRandom": "Random",
"entityLibrary": "Library",
diff --git a/booklore-ui/src/i18n/es/settings-view.json b/booklore-ui/src/i18n/es/settings-view.json
index c357cdb3d..6dcd09eb2 100644
--- a/booklore-ui/src/i18n/es/settings-view.json
+++ b/booklore-ui/src/i18n/es/settings-view.json
@@ -51,6 +51,7 @@
"sortDateFinished": "Fecha de finalización",
"sortReadingProgress": "Progreso de lectura",
"sortBookType": "Tipo de libro",
+ "sortNarrator": "Narrador",
"sortPages": "PƔginas",
"sortRandom": "Aleatorio",
"entityLibrary": "Biblioteca",