Audiobook enhancement (#2611)
* Audiobook enhancement * Fix choppy virtual scroller with mixed audiobook/ebook cards by using uniform heights * Fix audiobook cover regeneration for combined books and improve error messages * Fix cover extraction when attaching audiobook files during rescan * Set audiobookCoverUpdatedOn for cache busting when generating cover * Add support for regenerating covers from specific book files * Fix Continue Reading/Listening scrollers to filter by actual progress instead of primary file type * Show ebook cover and open ebook reader in Continue Reading scroller for combined books * Prevent read status from being downgraded when saving audiobook progress * Fix BookCoverServiceTest to match updated regenerateCover method signature --------- Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
+2
-1
@@ -23,10 +23,11 @@
|
||||
#scrollContainer
|
||||
[horizontal]="true">
|
||||
@for (book of books; track book.id) {
|
||||
<div class="dashboard-scroller-card" [class.menu-open]="openMenuBookId === book.id">
|
||||
<div class="dashboard-scroller-card" [ngClass]="{'menu-open': openMenuBookId === book.id, 'square-card': useSquareCovers}">
|
||||
<app-book-card
|
||||
[book]="book"
|
||||
[isCheckboxEnabled]="false"
|
||||
[forceEbookMode]="forceEbookMode"
|
||||
(menuToggled)="handleMenuToggle(book.id, $event)"
|
||||
[overlayPreferenceService]="bookCardOverlayPreferenceService"
|
||||
></app-book-card>
|
||||
|
||||
+17
@@ -96,6 +96,17 @@
|
||||
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
position: relative;
|
||||
|
||||
&.square-card {
|
||||
width: 160px;
|
||||
height: auto;
|
||||
flex-basis: 160px;
|
||||
|
||||
::ng-deep .cover-container.audiobook-cover {
|
||||
aspect-ratio: 1/1 !important;
|
||||
flex: none;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover, &.menu-open {
|
||||
transform: translateY(-4px) scale(1.04);
|
||||
filter: drop-shadow(0 25px 50px rgba(0, 0, 0, 0.4));
|
||||
@@ -180,6 +191,12 @@
|
||||
height: 184px;
|
||||
width: 108px;
|
||||
flex-basis: 108px;
|
||||
|
||||
&.square-card {
|
||||
width: 150px;
|
||||
height: auto;
|
||||
flex-basis: 150px;
|
||||
}
|
||||
}
|
||||
|
||||
.dashboard-scroller-no-books {
|
||||
|
||||
+8
-1
@@ -1,6 +1,7 @@
|
||||
import {Component, ElementRef, Input, ViewChild, inject} from '@angular/core';
|
||||
import {BookCardComponent} from '../../../book/components/book-browser/book-card/book-card.component';
|
||||
import {InfiniteScrollDirective} from 'ngx-infinite-scroll';
|
||||
import {NgClass} from '@angular/common';
|
||||
|
||||
import {ProgressSpinnerModule} from 'primeng/progressspinner';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
@@ -14,7 +15,8 @@ import { BookCardOverlayPreferenceService } from '../../../book/components/book-
|
||||
imports: [
|
||||
InfiniteScrollDirective,
|
||||
BookCardComponent,
|
||||
ProgressSpinnerModule
|
||||
ProgressSpinnerModule,
|
||||
NgClass
|
||||
],
|
||||
standalone: true
|
||||
})
|
||||
@@ -24,12 +26,17 @@ export class DashboardScrollerComponent {
|
||||
@Input() title!: string;
|
||||
@Input() books!: Book[] | null;
|
||||
@Input() isMagicShelf: boolean = false;
|
||||
@Input() useSquareCovers: boolean = false;
|
||||
|
||||
@ViewChild('scrollContainer') scrollContainer!: ElementRef;
|
||||
openMenuBookId: number | null = null;
|
||||
|
||||
public bookCardOverlayPreferenceService = inject(BookCardOverlayPreferenceService);
|
||||
|
||||
get forceEbookMode(): boolean {
|
||||
return this.bookListType === ScrollerType.LAST_READ;
|
||||
}
|
||||
|
||||
handleMenuToggle(bookId: number, isOpen: boolean) {
|
||||
this.openMenuBookId = isOpen ? bookId : null;
|
||||
}
|
||||
|
||||
+3
@@ -41,6 +41,7 @@ export class DashboardSettingsComponent implements OnInit {
|
||||
|
||||
availableScrollerTypes = [
|
||||
{label: 'Continue Reading', value: ScrollerType.LAST_READ},
|
||||
{label: 'Continue Listening', value: ScrollerType.LAST_LISTENED},
|
||||
{label: 'Recently Added', value: ScrollerType.LATEST_ADDED},
|
||||
{label: 'Discover Something New', value: ScrollerType.RANDOM},
|
||||
{label: 'Magic Shelf', value: ScrollerType.MAGIC_SHELF}
|
||||
@@ -102,6 +103,8 @@ export class DashboardSettingsComponent implements OnInit {
|
||||
switch (scroller.type) {
|
||||
case ScrollerType.LAST_READ:
|
||||
return 'Continue Reading';
|
||||
case ScrollerType.LAST_LISTENED:
|
||||
return 'Continue Listening';
|
||||
case ScrollerType.LATEST_ADDED:
|
||||
return 'Recently Added';
|
||||
case ScrollerType.RANDOM:
|
||||
|
||||
+1
@@ -57,6 +57,7 @@
|
||||
[bookListType]="scroller.type"
|
||||
[title]="scroller.title"
|
||||
[isMagicShelf]="scroller.type === ScrollerType.MAGIC_SHELF"
|
||||
[useSquareCovers]="scroller.type === ScrollerType.LAST_LISTENED"
|
||||
[books]="getBooksForScroller(scroller) | async">
|
||||
</app-dashboard-scroller>
|
||||
}
|
||||
|
||||
+30
-1
@@ -74,7 +74,11 @@ export class MainDashboardComponent implements OnInit {
|
||||
private getLastReadBooks(maxItems: number, sortBy?: string): Observable<Book[]> {
|
||||
return this.bookService.bookState$.pipe(
|
||||
map((state: BookState) => {
|
||||
let books = (state.books || []).filter(book => book.lastReadTime && (book.readStatus === ReadStatus.READING || book.readStatus === ReadStatus.RE_READING || book.readStatus === ReadStatus.PAUSED));
|
||||
let books = (state.books || []).filter(book =>
|
||||
book.lastReadTime &&
|
||||
(book.readStatus === ReadStatus.READING || book.readStatus === ReadStatus.RE_READING || book.readStatus === ReadStatus.PAUSED) &&
|
||||
this.hasEbookProgress(book)
|
||||
);
|
||||
books = books.sort((a, b) => {
|
||||
const aTime = new Date(a.lastReadTime!).getTime();
|
||||
const bTime = new Date(b.lastReadTime!).getTime();
|
||||
@@ -85,6 +89,28 @@ export class MainDashboardComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
private getLastListenedBooks(maxItems: number): Observable<Book[]> {
|
||||
return this.bookService.bookState$.pipe(
|
||||
map((state: BookState) => {
|
||||
let books = (state.books || []).filter(book =>
|
||||
book.lastReadTime &&
|
||||
(book.readStatus === ReadStatus.READING || book.readStatus === ReadStatus.RE_READING || book.readStatus === ReadStatus.PAUSED) &&
|
||||
book.audiobookProgress
|
||||
);
|
||||
books = books.sort((a, b) => {
|
||||
const aTime = new Date(a.lastReadTime!).getTime();
|
||||
const bTime = new Date(b.lastReadTime!).getTime();
|
||||
return bTime - aTime;
|
||||
});
|
||||
return books.slice(0, maxItems);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private hasEbookProgress(book: Book): boolean {
|
||||
return !!(book.epubProgress || book.pdfProgress || book.cbxProgress || book.koreaderProgress || book.koboProgress);
|
||||
}
|
||||
|
||||
private getLatestAddedBooks(maxItems: number, sortBy?: string): Observable<Book[]> {
|
||||
return this.bookService.bookState$.pipe(
|
||||
map((state: BookState) => {
|
||||
@@ -156,6 +182,9 @@ export class MainDashboardComponent implements OnInit {
|
||||
case ScrollerType.LAST_READ:
|
||||
books$ = this.getLastReadBooks(config.maxItems || DEFAULT_MAX_ITEMS);
|
||||
break;
|
||||
case ScrollerType.LAST_LISTENED:
|
||||
books$ = this.getLastListenedBooks(config.maxItems || DEFAULT_MAX_ITEMS);
|
||||
break;
|
||||
case ScrollerType.LATEST_ADDED:
|
||||
books$ = this.getLatestAddedBooks(config.maxItems || DEFAULT_MAX_ITEMS);
|
||||
break;
|
||||
|
||||
@@ -2,6 +2,7 @@ import {DEFAULT_MAX_ITEMS} from '../components/dashboard-settings/dashboard-sett
|
||||
|
||||
export enum ScrollerType {
|
||||
LAST_READ = 'lastRead',
|
||||
LAST_LISTENED = 'lastListened',
|
||||
LATEST_ADDED = 'latestAdded',
|
||||
RANDOM = 'random',
|
||||
MAGIC_SHELF = 'magicShelf'
|
||||
@@ -25,8 +26,9 @@ export interface DashboardConfig {
|
||||
|
||||
export const DEFAULT_DASHBOARD_CONFIG: DashboardConfig = {
|
||||
scrollers: [
|
||||
{id: '1', type: ScrollerType.LAST_READ, title: 'Continue Reading', enabled: true, order: 1, maxItems: DEFAULT_MAX_ITEMS},
|
||||
{id: '2', type: ScrollerType.LATEST_ADDED, title: 'Recently Added', enabled: true, order: 2, maxItems: DEFAULT_MAX_ITEMS},
|
||||
{id: '3', type: ScrollerType.RANDOM, title: 'Discover Something New', enabled: true, order: 3, maxItems: DEFAULT_MAX_ITEMS}
|
||||
{id: '1', type: ScrollerType.LAST_LISTENED, title: 'Continue Listening', enabled: true, order: 1, maxItems: DEFAULT_MAX_ITEMS},
|
||||
{id: '2', type: ScrollerType.LAST_READ, title: 'Continue Reading', enabled: true, order: 2, maxItems: DEFAULT_MAX_ITEMS},
|
||||
{id: '3', type: ScrollerType.LATEST_ADDED, title: 'Recently Added', enabled: true, order: 3, maxItems: DEFAULT_MAX_ITEMS},
|
||||
{id: '4', type: ScrollerType.RANDOM, title: 'Discover Something New', enabled: true, order: 4, maxItems: DEFAULT_MAX_ITEMS}
|
||||
]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user