Display other books from the same series on the metadata viewer page (#151)

* Display other books from the same series on the metadata viewer page

* feat(recommendations): filter out books from the same series as the target book

---------

Co-authored-by: adityachandelgit <>
This commit is contained in:
Aditya Chandel
2025-04-20 12:56:20 -06:00
committed by GitHub
co-authored by adityachandelgit
parent fd4b3c2bee
commit b8a493d264
6 changed files with 102 additions and 41 deletions
@@ -45,16 +45,9 @@ export class MetadataViewerComponent implements OnInit {
metadata$: Observable<BookMetadata | null> = this.metadataCenterService.currentMetadata$;
items: MenuItem[] | undefined;
recommendedBooks: BookRecommendation[] = [];
bookInSeries: Book[] = [];
isExpanded = false;
toggleExpand(): void {
this.isExpanded = !this.isExpanded;
}
shouldShowToggle(description?: string): boolean {
return (description?.length || 0) > 300;
}
ngOnInit(): void {
this.items = [
@@ -88,6 +81,18 @@ export class MetadataViewerComponent implements OnInit {
this.getBookRecommendations(metadata.bookId);
}
});
this.metadata$
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((metadata) => {
if (metadata) {
this.getBooksInSeries(metadata.bookId);
}
});
}
toggleExpand(): void {
this.isExpanded = !this.isExpanded;
}
getBookRecommendations(bookId: number): void {
@@ -96,6 +101,12 @@ export class MetadataViewerComponent implements OnInit {
});
}
getBooksInSeries(bookId: number): void {
this.bookService.getBooksInSeries(bookId).subscribe((bookInSeries) => {
this.bookInSeries = bookInSeries;
});
}
read(bookId: number): void {
this.bookService.readBook(bookId);
}