From 7053cfa9635cb88ec87d3079b2bf6c829a0293fa Mon Sep 17 00:00:00 2001 From: "aditya.chandel" Date: Fri, 6 Jun 2025 16:37:19 -0600 Subject: [PATCH] Fix sorting --- .../book-browser/book-browser.component.ts | 12 +++++++++--- .../components/pdf-viewer/pdf-viewer.component.ts | 1 - 2 files changed, 9 insertions(+), 4 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 62b683547..33bb82f49 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 @@ -670,14 +670,20 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { }; const userSortKey = effectivePrefs.sortKey; + const userSortDir = effectivePrefs.sortDir?.toUpperCase() === 'DESC' + ? SortDirection.DESCENDING + : SortDirection.ASCENDING; + const matchedSort = this.sortOptions.find(opt => opt.field === userSortKey) || this.sortOptions.find(opt => opt.field === sortParam); this.selectedSort = matchedSort ? { label: matchedSort.label, field: matchedSort.field, - direction: directionParam?.toUpperCase() === SORT_DIRECTION.DESCENDING - ? SortDirection.DESCENDING - : SortDirection.ASCENDING + direction: userSortDir ?? ( + directionParam?.toUpperCase() === SORT_DIRECTION.DESCENDING + ? SortDirection.DESCENDING + : SortDirection.ASCENDING + ) } : { label: 'Added On', field: 'addedOn', diff --git a/booklore-ui/src/app/book/components/pdf-viewer/pdf-viewer.component.ts b/booklore-ui/src/app/book/components/pdf-viewer/pdf-viewer.component.ts index 83eb64653..b386692ac 100644 --- a/booklore-ui/src/app/book/components/pdf-viewer/pdf-viewer.component.ts +++ b/booklore-ui/src/app/book/components/pdf-viewer/pdf-viewer.component.ts @@ -113,7 +113,6 @@ export class PdfViewerComponent implements OnInit, OnDestroy { onPdfPagesLoaded(event: any): void { this.totalPages = event.pagesCount; - console.log('Total pages loaded:', this.totalPages); } ngOnDestroy(): void {