Implement streaming EPUB reader with on-demand loading (#2350)
Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
+13
-7
@@ -555,13 +555,19 @@
|
||||
<p-divider layout="vertical" class="action-divider"></p-divider>
|
||||
}
|
||||
@if (book!.bookType === 'PDF') {
|
||||
@if (readMenuItems$ | async; as readItems) {
|
||||
<p-splitbutton label="Read" icon="pi pi-book" [model]="readItems" (onClick)="read(book.id, 'ngx')" severity="primary"/>
|
||||
@if (pdfReadMenuItems$ | async; as readItems) {
|
||||
<p-splitbutton label="Read" outlined icon="pi pi-book" [model]="readItems" (onClick)="read(book.id)" severity="primary"/>
|
||||
}
|
||||
}
|
||||
@if (book!.bookType !== 'PDF') {
|
||||
<p-button label="Read" icon="pi pi-book" (onClick)="read(book?.metadata!.bookId, undefined)" severity="primary"/>
|
||||
@if (book!.bookType === 'EPUB') {
|
||||
@if (epubReadMenuItems$ | async; as readItems) {
|
||||
<p-splitbutton label="Read" outlined icon="pi pi-book" [model]="readItems" (onClick)="read(book.id)" severity="primary"/>
|
||||
}
|
||||
}
|
||||
@if (book!.bookType !== 'PDF' && book!.bookType !== 'EPUB') {
|
||||
<p-button label="Read" outlined icon="pi pi-book" (onClick)="read(book?.metadata!.bookId, undefined)" severity="primary"/>
|
||||
}
|
||||
<p-divider layout="vertical"></p-divider>
|
||||
<p-button label="Shelf" icon="pi pi-folder" severity="info" outlined (onClick)="assignShelf(book.id)" class="mobile-icon-only"></p-button>
|
||||
@if (userState.user!.permissions.canDownload || userState.user!.permissions.admin) {
|
||||
@if ((book!.alternativeFormats && book!.alternativeFormats.length > 0) || (book!.supplementaryFiles && book!.supplementaryFiles.length > 0)) {
|
||||
@@ -575,7 +581,7 @@
|
||||
@if (userState.user!.permissions.canEditMetadata || userState.user!.permissions.admin) {
|
||||
@if (refreshMenuItems$ | async; as refreshItems) {
|
||||
<p-splitbutton
|
||||
[label]="isAutoFetching ? 'Fetching...' : 'Auto Fetch'"
|
||||
[label]="isAutoFetching ? 'Fetching...' : 'Fetch'"
|
||||
[icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
|
||||
[outlined]="true"
|
||||
[model]="refreshItems"
|
||||
@@ -584,13 +590,13 @@
|
||||
[disabled]="isAutoFetching"
|
||||
pTooltip="Automatically fetch metadata using default sources"
|
||||
tooltipPosition="top"
|
||||
styleClass="mobile-icon-only">
|
||||
class="mobile-icon-only">
|
||||
</p-splitbutton>
|
||||
}
|
||||
}
|
||||
@if (otherItems$ | async; as otherItems) {
|
||||
@if (otherItems.length > 0) {
|
||||
<p-button icon="pi pi-ellipsis-v" outlined severity="primary" (click)="entitymenu.toggle($event)"></p-button>
|
||||
<p-button icon="pi pi-ellipsis-v" outlined severity="danger" (click)="entitymenu.toggle($event)"></p-button>
|
||||
<p-tieredMenu #entitymenu [model]="otherItems" [popup]="true" appendTo="body"></p-tieredMenu>
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -472,7 +472,6 @@
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
+15
-4
@@ -70,7 +70,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private dialogRef?: DynamicDialogRef;
|
||||
|
||||
readMenuItems$!: Observable<MenuItem[]>;
|
||||
pdfReadMenuItems$!: Observable<MenuItem[]>;
|
||||
epubReadMenuItems$!: Observable<MenuItem[]>;
|
||||
refreshMenuItems$!: Observable<MenuItem[]>;
|
||||
otherItems$!: Observable<MenuItem[]>;
|
||||
downloadMenuItems$!: Observable<MenuItem[]>;
|
||||
@@ -116,12 +117,22 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
])
|
||||
);
|
||||
|
||||
this.readMenuItems$ = this.book$.pipe(
|
||||
this.pdfReadMenuItems$ = this.book$.pipe(
|
||||
filter((book): book is Book => book !== null),
|
||||
map((book): MenuItem[] => [
|
||||
{
|
||||
label: 'Streaming Reader',
|
||||
command: () => this.read(book.id, 'streaming')
|
||||
command: () => this.read(book.id, 'pdf-streaming')
|
||||
}
|
||||
])
|
||||
);
|
||||
|
||||
this.epubReadMenuItems$ = this.book$.pipe(
|
||||
filter((book): book is Book => book !== null),
|
||||
map((book): MenuItem[] => [
|
||||
{
|
||||
label: 'Streaming Reader (Beta)',
|
||||
command: () => this.read(book.id, 'epub-streaming')
|
||||
}
|
||||
])
|
||||
);
|
||||
@@ -369,7 +380,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
this.isExpanded = !this.isExpanded;
|
||||
}
|
||||
|
||||
read(bookId: number | undefined, reader: "ngx" | "streaming" | undefined): void {
|
||||
read(bookId: number | undefined, reader?: "pdf-streaming" | "epub-streaming"): void {
|
||||
if (bookId) this.bookService.readBook(bookId, reader);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user