Random sort option for libraries and shelves (#1817)

This commit is contained in:
Muppetteer
2025-12-11 14:43:18 +11:00
committed by GitHub
parent 78d8f8e596
commit 73b27944e2
3 changed files with 4 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ export class BookSorter {
{ label: 'Hardcover Rating', field: 'hardcoverRating', direction: SortDirection.ASCENDING },
{ label: 'Hardcover #', field: 'hardcoverReviewCount', direction: SortDirection.ASCENDING },
{ label: 'Pages', field: 'pageCount', direction: SortDirection.ASCENDING },
{ label: 'Random', field: 'random', direction: SortDirection.ASCENDING },
];
constructor(private applySortOption: (sort: SortOption) => void) {}

View File

@@ -95,6 +95,7 @@ export class SortService {
addedOn: (book) => book.addedOn ? new Date(book.addedOn).getTime() : null,
fileSizeKb: (book) => book.fileSizeKb || null,
fileName: (book) => book.fileName,
random: (book) => Math.random(),
};
applySort(books: Book[], selectedSort: SortOption | null): Book[] {

View File

@@ -44,7 +44,8 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
{label: 'Goodreads #', field: 'goodreadsReviewCount'},
{label: 'Hardcover Rating', field: 'hardcoverRating'},
{label: 'Hardcover #', field: 'hardcoverReviewCount'},
{label: 'Pages', field: 'pageCount'}
{label: 'Pages', field: 'pageCount'},
{label: 'Random', field: 'random'},
];
entityTypeOptions = [