Random sort option for libraries and shelves (#1817)

This commit is contained in:
Muppetteer
2025-12-10 20:43:18 -07:00
committed by GitHub
parent 78d8f8e596
commit 73b27944e2
3 changed files with 4 additions and 1 deletions
@@ -22,6 +22,7 @@ export class BookSorter {
{ label: 'Hardcover Rating', field: 'hardcoverRating', direction: SortDirection.ASCENDING }, { label: 'Hardcover Rating', field: 'hardcoverRating', direction: SortDirection.ASCENDING },
{ label: 'Hardcover #', field: 'hardcoverReviewCount', direction: SortDirection.ASCENDING }, { label: 'Hardcover #', field: 'hardcoverReviewCount', direction: SortDirection.ASCENDING },
{ label: 'Pages', field: 'pageCount', direction: SortDirection.ASCENDING }, { label: 'Pages', field: 'pageCount', direction: SortDirection.ASCENDING },
{ label: 'Random', field: 'random', direction: SortDirection.ASCENDING },
]; ];
constructor(private applySortOption: (sort: SortOption) => void) {} constructor(private applySortOption: (sort: SortOption) => void) {}
@@ -95,6 +95,7 @@ export class SortService {
addedOn: (book) => book.addedOn ? new Date(book.addedOn).getTime() : null, addedOn: (book) => book.addedOn ? new Date(book.addedOn).getTime() : null,
fileSizeKb: (book) => book.fileSizeKb || null, fileSizeKb: (book) => book.fileSizeKb || null,
fileName: (book) => book.fileName, fileName: (book) => book.fileName,
random: (book) => Math.random(),
}; };
applySort(books: Book[], selectedSort: SortOption | null): Book[] { applySort(books: Book[], selectedSort: SortOption | null): Book[] {
@@ -44,7 +44,8 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
{label: 'Goodreads #', field: 'goodreadsReviewCount'}, {label: 'Goodreads #', field: 'goodreadsReviewCount'},
{label: 'Hardcover Rating', field: 'hardcoverRating'}, {label: 'Hardcover Rating', field: 'hardcoverRating'},
{label: 'Hardcover #', field: 'hardcoverReviewCount'}, {label: 'Hardcover #', field: 'hardcoverReviewCount'},
{label: 'Pages', field: 'pageCount'} {label: 'Pages', field: 'pageCount'},
{label: 'Random', field: 'random'},
]; ];
entityTypeOptions = [ entityTypeOptions = [