Fix sorting.
Todo: Refactor BookBrowserComponent, it's piece of crap
This commit is contained in:
@@ -62,6 +62,7 @@ export class BookBrowserComponent implements OnInit {
|
|||||||
return fullPath === 'all-books' ? 'all-books' : null;
|
return fullPath === 'all-books' ? 'all-books' : null;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
this.entityType = 'all-books';
|
||||||
this.bookState$ = this.fetchAllBooks();
|
this.bookState$ = this.fetchAllBooks();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -241,10 +242,14 @@ export class BookBrowserComponent implements OnInit {
|
|||||||
|
|
||||||
updateSortOption(sortOption: SortOption): void {
|
updateSortOption(sortOption: SortOption): void {
|
||||||
this.selectedSort = sortOption;
|
this.selectedSort = sortOption;
|
||||||
const routeParam$ = this.getRouteParams();
|
if (this.entityType === 'all-books') {
|
||||||
this.bookState$ = routeParam$.pipe(
|
this.bookState$ = this.fetchAllBooks();
|
||||||
switchMap(({libraryId, shelfId}) => this.fetchBooksByEntity(libraryId, shelfId))
|
} else {
|
||||||
);
|
const routeParam$ = this.getRouteParams();
|
||||||
|
this.bookState$ = routeParam$.pipe(
|
||||||
|
switchMap(({libraryId, shelfId}) => this.fetchBooksByEntity(libraryId, shelfId))
|
||||||
|
);
|
||||||
|
}
|
||||||
if (this.entityType === 'Library') {
|
if (this.entityType === 'Library') {
|
||||||
this.libraryService.updateSort(this.entity?.id!, sortOption).subscribe();
|
this.libraryService.updateSort(this.entity?.id!, sortOption).subscribe();
|
||||||
} else if (this.entityType === 'Shelf') {
|
} else if (this.entityType === 'Shelf') {
|
||||||
|
|||||||
Reference in New Issue
Block a user