diff --git a/booklore-ui/src/app/book/components/book-browser/book-browser.component.html b/booklore-ui/src/app/book/components/book-browser/book-browser.component.html
index 9eb3fd0ba..4ceb4b74d 100644
--- a/booklore-ui/src/app/book/components/book-browser/book-browser.component.html
+++ b/booklore-ui/src/app/book/components/book-browser/book-browser.component.html
@@ -117,26 +117,6 @@
{{ coverScalePreferenceService.scaleFactor.toFixed(2) }}x
-
-
-
-
-
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 f6e0b2c6b..15265a9b5 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
@@ -36,8 +36,6 @@ import {BookDialogHelperService} from './BookDialogHelperService';
import {Checkbox} from 'primeng/checkbox';
import {Popover} from 'primeng/popover';
import {Slider} from 'primeng/slider';
-import {Select} from 'primeng/select';
-import {FilterSortPreferenceService} from './filters/filter-sorting-preferences.service';
import {Divider} from 'primeng/divider';
import {MultiSelect} from 'primeng/multiselect';
import {TableColumnPreferenceService} from './table-column-preference-service';
@@ -85,7 +83,7 @@ const SORT_DIRECTION = {
imports: [
Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule,
BookTableComponent, BookFilterComponent, Tooltip, NgClass, PrimeTemplate, NgStyle, Popover,
- Checkbox, Slider, Select, Divider, MultiSelect, TieredMenu
+ Checkbox, Slider, Divider, MultiSelect, TieredMenu
],
providers: [SeriesCollapseFilter],
animations: [
@@ -100,7 +98,6 @@ const SORT_DIRECTION = {
export class BookBrowserComponent implements OnInit {
protected userService = inject(UserService);
protected coverScalePreferenceService = inject(CoverScalePreferenceService);
- protected filterSortPreferenceService = inject(FilterSortPreferenceService);
protected columnPreferenceService = inject(TableColumnPreferenceService);
protected sidebarFilterTogglePrefService = inject(SidebarFilterTogglePrefService);
private activatedRoute = inject(ActivatedRoute);
@@ -274,7 +271,6 @@ export class BookBrowserComponent implements OnInit {
const globalPrefs = this.entityViewPreferences?.global;
const currentEntityTypeStr = this.entityType ? this.entityType.toString().toUpperCase() : undefined;
this.coverScalePreferenceService.initScaleValue(this.coverScalePreferenceService.scaleFactor);
- this.filterSortPreferenceService.initValue(user.user?.userSettings?.filterSortingMode);
this.columnPreferenceService.initPreferences(user.user?.userSettings?.tableColumnPreference);
this.visibleColumns = this.columnPreferenceService.visibleColumns;
diff --git a/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.html b/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.html
index 0c71348cd..bf3af256c 100644
--- a/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.html
+++ b/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.html
@@ -41,7 +41,11 @@
(click)="handleFilterClick(filterType, filter.value?.id || filter.value)">
{{ filter.value.name || filter.value }}
-
+
+ }
+ @if (truncatedFilters[filterType]) {
+
+ Showing first 250 items
}
@@ -50,5 +54,9 @@
}
+
+
+ Note: Top 500 items are displayed per filter category
+
diff --git a/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.ts b/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.ts
index 4e342f22a..dc650016f 100644
--- a/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.ts
+++ b/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.ts
@@ -1,5 +1,5 @@
import {ChangeDetectionStrategy, Component, EventEmitter, inject, Input, OnDestroy, OnInit, Output} from '@angular/core';
-import {combineLatest, distinctUntilChanged, Observable, of, shareReplay, Subject, takeUntil} from 'rxjs';
+import {combineLatest, Observable, of, shareReplay, Subject, takeUntil} from 'rxjs';
import {map} from 'rxjs/operators';
import {BookService} from '../../../service/book.service';
import {Library} from '../../../model/library.model';
@@ -12,7 +12,6 @@ import {Badge} from 'primeng/badge';
import {FormsModule} from '@angular/forms';
import {SelectButton} from 'primeng/selectbutton';
import {UserService} from '../../../../settings/user-management/user.service';
-import {FilterSortPreferenceService} from '../filters/filter-sorting-preferences.service';
import {MagicShelf} from '../../../../magic-shelf.service';
import {GroupRule} from '../../../../magic-shelf-component/magic-shelf-component';
import {BookRuleEvaluatorService} from '../../../../book-rule-evaluator.service';
@@ -161,6 +160,7 @@ export class BookFilterComponent implements OnInit, OnDestroy {
activeFilters: Record = {};
filterStreams: Record[]>> = {};
+ truncatedFilters: Record = {};
filterTypes: string[] = [];
filterModeOptions = [
{label: 'AND', value: 'and'},
@@ -190,38 +190,37 @@ export class BookFilterComponent implements OnInit, OnDestroy {
bookService = inject(BookService);
userService = inject(UserService);
- filterSortPreferenceService = inject(FilterSortPreferenceService);
bookRuleEvaluatorService = inject(BookRuleEvaluatorService);
ngOnInit(): void {
combineLatest([
- this.filterSortPreferenceService.sortMode$.pipe(distinctUntilChanged()),
this.entity$ ?? of(null),
this.entityType$ ?? of(EntityType.ALL_BOOKS)
])
.pipe(takeUntil(this.destroy$))
.subscribe(([sortMode]) => {
this.filterStreams = {
- // Temporarily disabled until we can optimize for large libraries
- /*author: this.getFilterStream((book: Book) => book.metadata?.authors!.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),
- category: this.getFilterStream((book: Book) => book.metadata?.categories!.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),*/
- series: this.getFilterStream((book) => (book.metadata?.seriesName ? [{id: book.metadata.seriesName, name: book.metadata.seriesName}] : []), 'id', 'name', sortMode),
- publisher: this.getFilterStream((book) => (book.metadata?.publisher ? [{id: book.metadata.publisher, name: book.metadata.publisher}] : []), 'id', 'name', sortMode),
+ author: this.getFilterStream((book: Book) => book.metadata?.authors!.map(name => ({id: name, name})) || [], 'id', 'name'),
+ category: this.getFilterStream((book: Book) => book.metadata?.categories!.map(name => ({id: name, name})) || [], 'id', 'name'),
+ series: this.getFilterStream((book) => (book.metadata?.seriesName ? [{id: book.metadata.seriesName, name: book.metadata.seriesName}] : []), 'id', 'name'),
+ publisher: this.getFilterStream((book) => (book.metadata?.publisher ? [{id: book.metadata.publisher, name: book.metadata.publisher}] : []), 'id', 'name'),
readStatus: this.getFilterStream((book: Book) => {
let status = book.readStatus;
if (status == null || !(status in readStatusLabels)) {
status = ReadStatus.UNSET;
}
return [{id: status, name: getReadStatusName(status)}];
- }, 'id', 'name', sortMode),
+ }, 'id', 'name'),
+ mood: this.getFilterStream((book: Book) => book.metadata?.moods!.map(name => ({id: name, name})) || [], 'id', 'name'),
+ tag: this.getFilterStream((book: Book) => book.metadata?.tags!.map(name => ({id: name, name})) || [], 'id', 'name'),
matchScore: this.getFilterStream((book: Book) => getMatchScoreRangeFilters(book.metadataMatchScore), 'id', 'name', 'sortIndex'),
personalRating: this.getFilterStream((book: Book) => getRatingRangeFilters10(book.metadata?.personalRating!), 'id', 'name', 'sortIndex'),
amazonRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.amazonRating!), 'id', 'name', 'sortIndex'),
goodreadsRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.goodreadsRating!), 'id', 'name', 'sortIndex'),
hardcoverRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.hardcoverRating!), 'id', 'name', 'sortIndex'),
- shelfStatus: this.getFilterStream(getShelfStatusFilter, 'id', 'name', sortMode),
- publishedDate: this.getFilterStream(extractPublishedYearFilter, 'id', 'name', sortMode),
- language: this.getFilterStream(getLanguageFilter, 'id', 'name', sortMode),
+ shelfStatus: this.getFilterStream(getShelfStatusFilter, 'id', 'name'),
+ publishedDate: this.getFilterStream(extractPublishedYearFilter, 'id', 'name'),
+ language: this.getFilterStream(getLanguageFilter, 'id', 'name'),
fileSize: this.getFilterStream((book: Book) => getFileSizeRangeFilters(book.fileSizeKb), 'id', 'name', 'sortIndex'),
pageCount: this.getFilterStream((book: Book) => getPageCountRangeFilters(book.metadata?.pageCount!), 'id', 'name', 'sortIndex'),
};
@@ -266,18 +265,31 @@ export class BookFilterComponent implements OnInit, OnDestroy {
const result = Array.from(filterMap.values());
- return result.sort((a, b) => {
+ const sorted = result.sort((a, b) => {
if (sortMode === 'sortIndex') {
return (a.value.sortIndex ?? 999) - (b.value.sortIndex ?? 999);
}
- if (sortMode === 'alphabetical') {
- return a.value[nameKey].toString().localeCompare(b.value[nameKey].toString());
- }
return (
b.bookCount - a.bookCount ||
a.value[nameKey].toString().localeCompare(b.value[nameKey].toString())
);
});
+
+ const isTruncated = sorted.length > 500;
+ const truncated = sorted.slice(0, 500);
+
+ return {items: truncated, isTruncated};
+ }),
+ map(({items, isTruncated}) => {
+ setTimeout(() => {
+ const filterType = Object.keys(this.filterStreams).find(key =>
+ this.filterStreams[key] === this.getFilterStream(extractor, idKey, nameKey)
+ );
+ if (filterType) {
+ this.truncatedFilters[filterType] = isTruncated;
+ }
+ });
+ return items;
}),
shareReplay({bufferSize: 1, refCount: true})
);
diff --git a/booklore-ui/src/app/book/components/book-browser/filters/filter-sorting-preferences.service.ts b/booklore-ui/src/app/book/components/book-browser/filters/filter-sorting-preferences.service.ts
deleted file mode 100644
index e9fbb8510..000000000
--- a/booklore-ui/src/app/book/components/book-browser/filters/filter-sorting-preferences.service.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import {inject, Injectable} from '@angular/core';
-import {BehaviorSubject} from 'rxjs';
-import {UserService} from '../../../../settings/user-management/user.service';
-import {MessageService} from 'primeng/api';
-
-@Injectable({
- providedIn: 'root'
-})
-export class FilterSortPreferenceService {
-
- readonly filterSortingOptions = [
- { label: 'Alphabetical (A–Z)', value: 'alphabetical' },
- { label: 'Book Count (High to Low)', value: 'count' }
- ];
-
- private readonly userService = inject(UserService);
- private readonly messageService = inject(MessageService);
-
- private readonly sortModeSubject = new BehaviorSubject<'alphabetical' | 'count'>('count');
- readonly sortMode$ = this.sortModeSubject.asObservable();
-
- initValue(value: 'alphabetical' | 'count' | null | undefined): void {
- const resolved = value ?? 'count';
- this.sortModeSubject.next(resolved);
- }
-
- get selectedFilterSorting(): 'alphabetical' | 'count' {
- return this.sortModeSubject.value;
- }
-
- set selectedFilterSorting(value: 'alphabetical' | 'count') {
- if (this.sortModeSubject.value !== value) {
- this.sortModeSubject.next(value);
- this.savePreference(value);
- }
- }
-
- private savePreference(value: 'alphabetical' | 'count'): void {
- const user = this.userService.getCurrentUser();
- if (!user) return;
-
- user.userSettings.filterSortingMode = value;
- this.userService.updateUserSetting(user.id, 'filterSortingMode', value);
-
- this.messageService.add({
- severity: 'success',
- summary: 'Preferences Updated',
- detail: 'Your filter sorting preference has been saved.',
- life: 1500
- });
- }
-}