Fix Dashboard

This commit is contained in:
aditya.chandel
2024-12-18 16:41:30 -07:00
parent ce515649f6
commit de8846ea8e
4 changed files with 14 additions and 42 deletions
@@ -11,9 +11,7 @@
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
#scrollContainer
[horizontal]="true"
(scrolled)="loadMore()"
(scroll)="onScroll($event)">
[horizontal]="true">
<div class="book-item" *ngFor="let book of booksSignal()">
<img [src]="coverImageSrc(book.id)" class="book-cover" alt="Cover of {{ book.metadata.title }}" loading="lazy"/>
<div class="book-info">
@@ -23,8 +23,6 @@ export class DashboardScrollerComponent implements OnInit {
@Input() title: string = 'Last Read Books';
@ViewChild('scrollContainer') scrollContainer!: ElementRef;
private currentPage: number = 0;
booksSignal = computed(() => {
return this.bookListType === 'lastRead' ? this.bookService.lastReadBooks() : this.bookService.latestAddedBooks();
});
@@ -37,12 +35,11 @@ export class DashboardScrollerComponent implements OnInit {
}
loadBooks(): void {
if (this.bookListType === 'lastRead') {
this.bookService.getLastReadBooks(this.currentPage);
} else {
this.bookService.getLatestAddedBooks(this.currentPage);
if (this.bookListType === 'lastRead' && !this.bookService.lastReadBooksLoaded) {
this.bookService.getLastReadBooks();
} else if (this.bookListType === 'latestAdded' && !this.bookService.latestAddedBooksLoaded) {
this.bookService.getLatestAddedBooks();
}
this.currentPage++;
}
coverImageSrc(bookId: number): string {
@@ -58,20 +55,6 @@ export class DashboardScrollerComponent implements OnInit {
window.open(url, '_blank');
}
loadMore() {
/*this.loadBooks();
this.currentPage++;*/
}
onScroll(event: any): void {
/*const container = this.scrollContainer.nativeElement;
const scrollRight = container.scrollWidth - container.scrollLeft === container.clientWidth;
if (scrollRight) {
this.currentPage++;
this.loadBooks();
}*/
}
openBookInfo(bookId: number, libraryId: number) {
this.router.navigate(['/library', libraryId, 'book', bookId, 'info']);
}