Add toggle to enable/disable book recommendations (#152)
Co-authored-by: adityachandelgit
This commit is contained in:
co-authored by
adityachandelgit
parent
b8a493d264
commit
c903044dc1
+1
-1
@@ -93,7 +93,7 @@
|
||||
|
||||
<p-divider></p-divider>
|
||||
|
||||
<ng-container *ngIf="recommendedBooks.length > 0">
|
||||
<ng-container *ngIf="similarBookRecommendation && recommendedBooks.length > 0">
|
||||
<div>
|
||||
<h3 class="text-xl font-semibold">Similar Books</h3>
|
||||
<div class="dashboard-scroller-infinite"
|
||||
|
||||
+22
-6
@@ -21,6 +21,9 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
import {InfiniteScrollDirective} from 'ngx-infinite-scroll';
|
||||
import {BookCardComponent} from '../../../book/components/book-browser/book-card/book-card.component';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {AppSettingsService} from '../../../core/service/app-settings.service';
|
||||
import {AppSettings} from '../../../core/model/app-settings.model';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-viewer',
|
||||
@@ -41,13 +44,15 @@ export class MetadataViewerComponent implements OnInit {
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
protected userService = inject(UserService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
|
||||
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
|
||||
metadata$: Observable<BookMetadata | null> = this.metadataCenterService.currentMetadata$;
|
||||
items: MenuItem[] | undefined;
|
||||
recommendedBooks: BookRecommendation[] = [];
|
||||
bookInSeries: Book[] = [];
|
||||
isExpanded = false;
|
||||
|
||||
similarBookRecommendation = false;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.items = [
|
||||
@@ -74,11 +79,22 @@ export class MetadataViewerComponent implements OnInit {
|
||||
}
|
||||
];
|
||||
|
||||
this.metadata$
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((metadata) => {
|
||||
if (metadata) {
|
||||
this.getBookRecommendations(metadata.bookId);
|
||||
this.appSettings$
|
||||
.pipe(
|
||||
filter(settings => settings != null),
|
||||
take(1)
|
||||
)
|
||||
.subscribe(settings => {
|
||||
this.similarBookRecommendation = settings!.similarBookRecommendation ?? false;
|
||||
if (this.similarBookRecommendation) {
|
||||
this.metadata$
|
||||
.pipe(
|
||||
filter((metadata): metadata is BookMetadata => metadata !== null),
|
||||
take(1)
|
||||
)
|
||||
.subscribe(metadata => {
|
||||
this.getBookRecommendations(metadata.bookId);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user