From 43389c8dc4835a6d2991f4b97e78bb962f684598 Mon Sep 17 00:00:00 2001 From: James Cox Date: Wed, 25 Mar 2026 22:41:23 -0500 Subject: [PATCH] fix(ui): restore frontend verification after eslint cleanup - Reader and metadata typing: - align ebook and cbx reader event, progress, dialog, and helper types with the stricter checks surfaced by the ESLint cleanup - replace unsafe non-null assertions and broad event assumptions with guarded access in reader, metadata, and shelf flows - Template and component compatibility: - tighten menu item typing for Angular template checking and normalize overlay and card click handlers to use explicit DOM event types - repair chart, preferences, and websocket factory typings that broke standalone typecheck and production build validation - Tests: - fix the magic shelf form-array assertion so the frontend test suite compiles cleanly under the stricter checker - Validation: - `just ui check` - `just ui typecheck` - `just ui test` --- .../author-card/author-card.component.ts | 5 +-- .../book-card/book-card.component.ts | 4 +-- .../duplicate-merger.component.ts | 4 +-- .../service/library-shelf-menu.service.ts | 19 +++++++--- .../component/magic-shelf-component.spec.ts | 5 +-- .../metadata-editor.component.ts | 10 ++++-- .../metadata-searcher.component.ts | 5 +-- .../cbx-reader/cbx-reader.component.ts | 2 +- .../dialogs/cbx-note-dialog.component.ts | 2 +- .../dialogs/cbx-shortcuts-help.component.ts | 2 +- .../ebook-reader/core/event.service.ts | 2 +- .../ebook-reader/core/view-manager.service.ts | 29 ++++++++++----- .../dialogs/metadata-dialog.component.html | 4 +-- .../dialogs/note-dialog.component.ts | 2 +- .../dialogs/settings-dialog.component.html | 4 +-- .../dialogs/shortcuts-help.component.ts | 2 +- .../ebook-reader/ebook-reader.component.ts | 4 +-- .../annotation-renderer.service.ts | 2 +- .../layout/footer/footer.component.ts | 36 ++++--------------- .../ebook-reader/shared/header-footer.util.ts | 5 +-- .../shared/selection-popup.component.ts | 2 +- .../ebook-reader/state/progress.service.ts | 4 +-- .../series-card/series-card.component.ts | 2 +- .../epub-reader-preferences-component.ts | 4 +-- .../reader-preferences.service.ts | 2 +- .../filter-preferences.component.ts | 2 +- .../sidebar-sorting-preferences.component.ts | 2 +- .../reading-debt-chart.component.ts | 6 ++-- .../layout-menu/app.menuitem.component.ts | 27 ++++++++++++-- .../websocket/rx-stomp-service-factory.ts | 3 +- 30 files changed, 115 insertions(+), 87 deletions(-) diff --git a/frontend/src/app/features/author-browser/components/author-card/author-card.component.ts b/frontend/src/app/features/author-browser/components/author-card/author-card.component.ts index d9993cdba..057921da8 100644 --- a/frontend/src/app/features/author-browser/components/author-card/author-card.component.ts +++ b/frontend/src/app/features/author-browser/components/author-card/author-card.component.ts @@ -70,12 +70,13 @@ export class AuthorCardComponent implements OnChanges { return !!this.author.asin; } - onCardClick(event: MouseEvent): void { + onCardClick(event: Event): void { const target = event.target as HTMLElement; if (target.closest('.menu-button-container')) { return; } - if (event.ctrlKey || event.metaKey) { + const isModifierClick = (event instanceof MouseEvent || event instanceof KeyboardEvent) && (event.ctrlKey || event.metaKey); + if (isModifierClick) { event.preventDefault(); event.stopPropagation(); this.toggleCardSelection(!this.isSelected); diff --git a/frontend/src/app/features/book/components/book-browser/book-card/book-card.component.ts b/frontend/src/app/features/book/components/book-browser/book-card/book-card.component.ts index 9d3c3213f..4fbf74f16 100644 --- a/frontend/src/app/features/book/components/book-browser/book-card/book-card.component.ts +++ b/frontend/src/app/features/book/components/book-browser/book-card/book-card.component.ts @@ -893,8 +893,8 @@ export class BookCardComponent implements OnInit, OnChanges { this.lastMouseEvent = event; } - onCardClick(event: MouseEvent): void { - if (!event.ctrlKey) { + onCardClick(event: Event): void { + if (!(event instanceof MouseEvent || event instanceof KeyboardEvent) || !event.ctrlKey) { return; } diff --git a/frontend/src/app/features/book/components/duplicate-merger/duplicate-merger.component.ts b/frontend/src/app/features/book/components/duplicate-merger/duplicate-merger.component.ts index a105b08a8..6dedee536 100644 --- a/frontend/src/app/features/book/components/duplicate-merger/duplicate-merger.component.ts +++ b/frontend/src/app/features/book/components/duplicate-merger/duplicate-merger.component.ts @@ -191,8 +191,8 @@ export class DuplicateMergerComponent implements OnInit, OnDestroy { } onPageChange(event: PaginatorState): void { - this.pageFirst = event.first; - this.pageSize = event.rows; + this.pageFirst = event.first ?? 0; + this.pageSize = event.rows ?? this.pageSize; } getBookFormats(book: Book): string[] { diff --git a/frontend/src/app/features/book/service/library-shelf-menu.service.ts b/frontend/src/app/features/book/service/library-shelf-menu.service.ts index d2a075270..cbce43264 100644 --- a/frontend/src/app/features/book/service/library-shelf-menu.service.ts +++ b/frontend/src/app/features/book/service/library-shelf-menu.service.ts @@ -85,7 +85,9 @@ export class LibraryShelfMenuService { severity: 'success', }, accept: () => { - this.libraryService.refreshLibrary(entity!.id).subscribe({ + const entityId = entity?.id; + if (entityId == null) return; + this.libraryService.refreshLibrary(entityId).subscribe({ complete: () => { this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfMenuService.toast.libraryRefreshSuccessDetail')}); }, @@ -147,8 +149,13 @@ export class LibraryShelfMenuService { }, accept: () => { const loader = this.loadingService.show(this.t.translate('book.shelfMenuService.loading.deletingLibrary', {name: entity?.name})); + const entityId = entity?.id; + if (entityId == null) { + this.loadingService.hide(loader); + return; + } - this.libraryService.deleteLibrary(entity!.id) + this.libraryService.deleteLibrary(entityId) .pipe(finalize(() => this.loadingService.hide(loader))) .subscribe({ complete: () => { @@ -212,7 +219,9 @@ export class LibraryShelfMenuService { severity: 'secondary' }, accept: () => { - this.shelfService.deleteShelf(entity!.id).subscribe({ + const entityId = entity?.id; + if (entityId == null) return; + this.shelfService.deleteShelf(entityId).subscribe({ complete: () => { this.router.navigate(['/']); this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfMenuService.toast.shelfDeletedDetail')}); @@ -284,7 +293,9 @@ export class LibraryShelfMenuService { severity: 'secondary' }, accept: () => { - this.magicShelfService.deleteShelf(entity!.id).subscribe({ + const entityId = entity?.id; + if (entityId == null) return; + this.magicShelfService.deleteShelf(entityId).subscribe({ complete: () => { this.router.navigate(['/']); this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfMenuService.toast.magicShelfDeletedDetail')}); diff --git a/frontend/src/app/features/magic-shelf/component/magic-shelf-component.spec.ts b/frontend/src/app/features/magic-shelf/component/magic-shelf-component.spec.ts index c5c01c0da..12625bc17 100644 --- a/frontend/src/app/features/magic-shelf/component/magic-shelf-component.spec.ts +++ b/frontend/src/app/features/magic-shelf/component/magic-shelf-component.spec.ts @@ -658,8 +658,9 @@ describe('MagicShelfComponent (Part 3)', () => { const rulesArray = result.get('rules') as FormArray; expect(rulesArray.length).toBe(2); const nestedGroup = rulesArray.at(1); - expect(nestedGroup.get('rules')).toBeDefined(); - expect(nestedGroup.get('rules').length).toBe(1); + const nestedRules = nestedGroup.get('rules') as FormArray; + expect(nestedRules).toBeDefined(); + expect(nestedRules.length).toBe(1); }); it('should preserve join type', () => { diff --git a/frontend/src/app/features/metadata/component/book-metadata-center/metadata-editor/metadata-editor.component.ts b/frontend/src/app/features/metadata/component/book-metadata-center/metadata-editor/metadata-editor.component.ts index 0fd7644ec..ffd4ddbb3 100644 --- a/frontend/src/app/features/metadata/component/book-metadata-center/metadata-editor/metadata-editor.component.ts +++ b/frontend/src/app/features/metadata/component/book-metadata-center/metadata-editor/metadata-editor.component.ts @@ -958,11 +958,17 @@ export class MetadataEditorComponent implements OnInit { detail: this.t.translate('metadata.editor.toast.coverRegenerated'), }); }, - error: () => { + error: (err: unknown) => { + const errorMessage = + err && typeof err === 'object' && 'error' in err && err.error && + typeof err.error === 'object' && 'message' in err.error && + typeof err.error.message === 'string' + ? err.error.message + : this.t.translate('metadata.editor.toast.coverRegenFailed'); this.messageService.add({ severity: "error", summary: this.t.translate('metadata.editor.toast.errorSummary'), - detail: err?.error?.message || this.t.translate('metadata.editor.toast.coverRegenFailed'), + detail: errorMessage, }); } }); diff --git a/frontend/src/app/features/metadata/component/book-metadata-center/metadata-searcher/metadata-searcher.component.ts b/frontend/src/app/features/metadata/component/book-metadata-center/metadata-searcher/metadata-searcher.component.ts index 4ec326085..1bd070841 100644 --- a/frontend/src/app/features/metadata/component/book-metadata-center/metadata-searcher/metadata-searcher.component.ts +++ b/frontend/src/app/features/metadata/component/book-metadata-center/metadata-searcher/metadata-searcher.component.ts @@ -318,10 +318,11 @@ export class MetadataSearcherComponent implements OnDestroy, OnChanges { ]; } - onProviderPillClick(provider: string, event: MouseEvent | KeyboardEvent): void { + onProviderPillClick(provider: string, event: Event): void { const providerLower = provider.toLowerCase(); - if (event.ctrlKey || event.metaKey) { + const isModifierClick = (event instanceof MouseEvent || event instanceof KeyboardEvent) && (event.ctrlKey || event.metaKey); + if (isModifierClick) { if (this.selectedProviderFilters.has(providerLower)) { this.selectedProviderFilters.delete(providerLower); } else { diff --git a/frontend/src/app/features/readers/cbx-reader/cbx-reader.component.ts b/frontend/src/app/features/readers/cbx-reader/cbx-reader.component.ts index d6aed8919..db8c1fcd1 100644 --- a/frontend/src/app/features/readers/cbx-reader/cbx-reader.component.ts +++ b/frontend/src/app/features/readers/cbx-reader/cbx-reader.component.ts @@ -1069,7 +1069,7 @@ export class CbxReaderComponent implements OnInit, OnDestroy { } } - @HostListener('document:mouseleave', ['$event']) + @HostListener('document:mouseleave') onMouseLeave(): void { this.visibilityManager.handleMouseLeave(); if (this.isMagnifierActive) { diff --git a/frontend/src/app/features/readers/cbx-reader/dialogs/cbx-note-dialog.component.ts b/frontend/src/app/features/readers/cbx-reader/dialogs/cbx-note-dialog.component.ts index cacbc566a..a3f5d8728 100644 --- a/frontend/src/app/features/readers/cbx-reader/dialogs/cbx-note-dialog.component.ts +++ b/frontend/src/app/features/readers/cbx-reader/dialogs/cbx-note-dialog.component.ts @@ -72,7 +72,7 @@ export class CbxNoteDialogComponent implements OnChanges { this.selectedColor = color; } - onOverlayClick(event: MouseEvent): void { + onOverlayClick(event: Event): void { if ((event.target as HTMLElement).classList.contains('dialog-overlay')) { this.onCancel(); } diff --git a/frontend/src/app/features/readers/cbx-reader/dialogs/cbx-shortcuts-help.component.ts b/frontend/src/app/features/readers/cbx-reader/dialogs/cbx-shortcuts-help.component.ts index ed0bb196e..8fdcd3aa1 100644 --- a/frontend/src/app/features/readers/cbx-reader/dialogs/cbx-shortcuts-help.component.ts +++ b/frontend/src/app/features/readers/cbx-reader/dialogs/cbx-shortcuts-help.component.ts @@ -73,7 +73,7 @@ export class CbxShortcutsHelpComponent { this.closed.emit(); } - onOverlayClick(event: MouseEvent): void { + onOverlayClick(event: Event): void { if ((event.target as HTMLElement).classList.contains('dialog-overlay')) { this.onClose(); } diff --git a/frontend/src/app/features/readers/ebook-reader/core/event.service.ts b/frontend/src/app/features/readers/ebook-reader/core/event.service.ts index a125f53e4..c92259282 100644 --- a/frontend/src/app/features/readers/ebook-reader/core/event.service.ts +++ b/frontend/src/app/features/readers/ebook-reader/core/event.service.ts @@ -172,7 +172,7 @@ export class ReaderEventService { const overlayerStyle = this.annotationService.getOverlayerDrawFunction(storedStyle.style); draw(overlayerStyle, {color: storedStyle.color}); } - this.eventSubject.next({type: 'draw-annotation', detail: {annotation, doc, range}}); + this.eventSubject.next({type: 'draw-annotation', detail: {draw, annotation, doc, range}}); }); this.view.addEventListener('show-annotation', (event: Event) => { diff --git a/frontend/src/app/features/readers/ebook-reader/core/view-manager.service.ts b/frontend/src/app/features/readers/ebook-reader/core/view-manager.service.ts index f8f5395d9..78320fb40 100644 --- a/frontend/src/app/features/readers/ebook-reader/core/view-manager.service.ts +++ b/frontend/src/app/features/readers/ebook-reader/core/view-manager.service.ts @@ -28,7 +28,7 @@ export interface BookMetadata { publisher?: string; description?: string; identifier?: string; - coverUrl?: string; + coverUrl?: string | null; [key: string]: unknown; } @@ -84,6 +84,8 @@ interface FoliateViewElement extends HTMLElement { getCFI(index: number, range: Range): string | null; deselect(): void; addAnnotation(annotation: { value: string }): void; + deleteAnnotation(annotation: { value: string }): Promise; + showAnnotation(annotation: { value: string }): Promise; getSectionFractions?(): number[]; search?(opts: { query: string; matchCase?: boolean; matchWholeWords?: boolean }): AsyncGenerator; clearSearch?(): void; @@ -122,7 +124,7 @@ export class ReaderViewManagerService { this.eventService.initialize(this.view, { prev: () => this.prev(), next: () => this.next(), - getCFI: (index: number, range: Range) => this.view?.getCFI(index, range), + getCFI: (index: number, range: Range) => this.view?.getCFI(index, range) ?? null, getContents: () => this.view?.renderer?.getContents() ?? null }); } @@ -132,6 +134,7 @@ export class ReaderViewManagerService { return throwError(() => new Error('View not created')); } + const view = this.view; return timer(100).pipe( switchMap(() => from(fetch(epubPath))), switchMap(response => { @@ -144,7 +147,7 @@ export class ReaderViewManagerService { const file = new File([blob], epubPath.split('/').pop() || 'book.epub', { type: 'application/epub+zip' }); - return from(this.view.open(file) as Promise); + return from(view.open(file) as Promise); }), map(() => undefined), catchError(err => throwError(() => err)) @@ -171,7 +174,11 @@ export class ReaderViewManagerService { const baseUrl = this.epubStreamingService.getBaseUrl(); const authToken = this.epubStreamingService.getAuthToken(); const book = await makeStreamingBook(bookId, baseUrl, bookInfo, authToken, bookType); - await this.view.open(book); + const view = this.view; + if (!view) { + throw new Error('View not created'); + } + await view.open(book); } destroy(): void { @@ -185,8 +192,9 @@ export class ReaderViewManagerService { if (!this.view) { return of(undefined); } + const view = this.view; return defer(() => - from(this.view.goTo(resolvedTarget) as Promise) + from(view.goTo(resolvedTarget) as Promise) ).pipe( map(() => undefined) ); @@ -200,7 +208,8 @@ export class ReaderViewManagerService { if (!this.view) { return of(undefined); } - return defer(() => from(this.view.goToFraction(fraction) as Promise)).pipe( + const view = this.view; + return defer(() => from(view.goToFraction(fraction) as Promise)).pipe( map(() => undefined) ); } @@ -304,8 +313,9 @@ export class ReaderViewManagerService { if (!this.view?.book?.getCover) { return of(null); } + const book = this.view.book; return defer(() => { - const coverPromise = this.view.book.getCover(); + const coverPromise = book.getCover?.(); return coverPromise ? from(coverPromise as Promise) : of(null); }); } @@ -317,8 +327,9 @@ export class ReaderViewManagerService { } async* search(opts: { query: string; matchCase?: boolean; matchWholeWords?: boolean }): AsyncGenerator { - if (!this.view?.search) return; - yield* this.view.search(opts); + const search = this.view?.search; + if (!search) return; + yield* search.call(this.view, opts); } clearSearch(): void { diff --git a/frontend/src/app/features/readers/ebook-reader/dialogs/metadata-dialog.component.html b/frontend/src/app/features/readers/ebook-reader/dialogs/metadata-dialog.component.html index 37b7ff627..1c641c109 100644 --- a/frontend/src/app/features/readers/ebook-reader/dialogs/metadata-dialog.component.html +++ b/frontend/src/app/features/readers/ebook-reader/dialogs/metadata-dialog.component.html @@ -1,9 +1,9 @@ -
+

{{ t('title') }}

- +
diff --git a/frontend/src/app/features/readers/ebook-reader/dialogs/note-dialog.component.ts b/frontend/src/app/features/readers/ebook-reader/dialogs/note-dialog.component.ts index 26c7f2803..ee5cc8c32 100644 --- a/frontend/src/app/features/readers/ebook-reader/dialogs/note-dialog.component.ts +++ b/frontend/src/app/features/readers/ebook-reader/dialogs/note-dialog.component.ts @@ -70,7 +70,7 @@ export class ReaderNoteDialogComponent implements OnChanges { this.selectedColor = color; } - onOverlayClick(event: MouseEvent): void { + onOverlayClick(event: Event): void { if ((event.target as HTMLElement).classList.contains('dialog-overlay')) { this.onCancel(); } diff --git a/frontend/src/app/features/readers/ebook-reader/dialogs/settings-dialog.component.html b/frontend/src/app/features/readers/ebook-reader/dialogs/settings-dialog.component.html index d9465d50c..928943413 100644 --- a/frontend/src/app/features/readers/ebook-reader/dialogs/settings-dialog.component.html +++ b/frontend/src/app/features/readers/ebook-reader/dialogs/settings-dialog.component.html @@ -1,5 +1,5 @@ -
+
@@ -22,7 +22,7 @@ {{ t('layoutTab') }}
- +
diff --git a/frontend/src/app/features/readers/ebook-reader/dialogs/shortcuts-help.component.ts b/frontend/src/app/features/readers/ebook-reader/dialogs/shortcuts-help.component.ts index 8fd83995c..445bf0201 100644 --- a/frontend/src/app/features/readers/ebook-reader/dialogs/shortcuts-help.component.ts +++ b/frontend/src/app/features/readers/ebook-reader/dialogs/shortcuts-help.component.ts @@ -71,7 +71,7 @@ export class EbookShortcutsHelpComponent { this.closed.emit(); } - onOverlayClick(event: MouseEvent): void { + onOverlayClick(event: Event): void { if ((event.target as HTMLElement).classList.contains('dialog-overlay')) { this.onClose(); } diff --git a/frontend/src/app/features/readers/ebook-reader/ebook-reader.component.ts b/frontend/src/app/features/readers/ebook-reader/ebook-reader.component.ts index ec8aca19a..324758029 100644 --- a/frontend/src/app/features/readers/ebook-reader/ebook-reader.component.ts +++ b/frontend/src/app/features/readers/ebook-reader/ebook-reader.component.ts @@ -424,12 +424,12 @@ export class EbookReaderComponent implements OnInit, OnDestroy { this.visibilityManager.handleMouseMove(event.clientY); } - @HostListener('document:mouseleave', ['$event']) + @HostListener('document:mouseleave') onMouseLeave(): void { this.visibilityManager.handleMouseLeave(); } - @HostListener('window:resize', ['$event']) + @HostListener('window:resize') onWindowResize(): void { this.visibilityManager.updateWindowHeight(window.innerHeight); } diff --git a/frontend/src/app/features/readers/ebook-reader/features/annotations/annotation-renderer.service.ts b/frontend/src/app/features/readers/ebook-reader/features/annotations/annotation-renderer.service.ts index f17859b89..95de0f4b0 100644 --- a/frontend/src/app/features/readers/ebook-reader/features/annotations/annotation-renderer.service.ts +++ b/frontend/src/app/features/readers/ebook-reader/features/annotations/annotation-renderer.service.ts @@ -11,7 +11,7 @@ export interface Annotation { } interface AnnotationView { - addAnnotation(annotation: { value: string }): Promise<{ index: number; label: string } | undefined>; + addAnnotation(annotation: { value: string }): Promise<{ index: number; label: string } | undefined> | void; deleteAnnotation(annotation: { value: string }): Promise; showAnnotation(annotation: { value: string }): Promise; } diff --git a/frontend/src/app/features/readers/ebook-reader/layout/footer/footer.component.ts b/frontend/src/app/features/readers/ebook-reader/layout/footer/footer.component.ts index a821abda0..673113cd8 100644 --- a/frontend/src/app/features/readers/ebook-reader/layout/footer/footer.component.ts +++ b/frontend/src/app/features/readers/ebook-reader/layout/footer/footer.component.ts @@ -2,31 +2,7 @@ import {Component, EventEmitter, HostListener, inject, Input, Output} from '@ang import {TranslocoDirective} from '@jsverse/transloco'; import {ReaderViewManagerService} from '../../core/view-manager.service'; import {ReaderIconComponent} from '../../shared/icon.component'; - -interface TocItem { - label: string; - href: string; - subitems?: TocItem[]; - id: number; -} - -interface PageItem { - label: string; - href: string; - subitems?: PageItem[]; - id: number; -} - -interface RelocateEventDetail { - fraction: number; - section: { current: number; total: number }; - location: { current: number; next: number; total: number }; - time: { section: number; total: number }; - tocItem: TocItem; - pageItem: PageItem; - cfi: string; - range: Range | null; -} +import {RelocateProgressData} from '../../state/progress.service'; @Component({ selector: 'app-reader-navbar', @@ -36,7 +12,7 @@ interface RelocateEventDetail { styleUrls: ['./footer.component.scss'] }) export class ReaderNavbarComponent { - @Input() progressData: RelocateEventDetail | null = null; + @Input() progressData: RelocateProgressData | null = null; @Input() forceVisible = false; @Input() set sectionFractions(value: number[]) { this._sectionFractions = value.filter(f => f > 0.001 && f < 0.999); @@ -82,19 +58,19 @@ export class ReaderNavbarComponent { } get timeTotal(): string { - return this.formatDuration((this.progressData?.time.total ?? 0) * 60); + return this.formatDuration((this.progressData?.time?.total ?? 0) * 60); } get timeSection(): string { - return this.formatDuration((this.progressData?.time.section ?? 0) * 60); + return this.formatDuration((this.progressData?.time?.section ?? 0) * 60); } get sectionCurrent(): number { - return this.progressData?.section.current ?? 0; + return this.progressData?.section?.current ?? 0; } get sectionTotal(): number { - return this.progressData?.section.total ?? 0; + return this.progressData?.section?.total ?? 0; } get currentChapter(): string { diff --git a/frontend/src/app/features/readers/ebook-reader/shared/header-footer.util.ts b/frontend/src/app/features/readers/ebook-reader/shared/header-footer.util.ts index 0f179d434..0c1f16f3d 100644 --- a/frontend/src/app/features/readers/ebook-reader/shared/header-footer.util.ts +++ b/frontend/src/app/features/readers/ebook-reader/shared/header-footer.util.ts @@ -51,10 +51,11 @@ export class PageDecorator { } const footerStyle = this.buildStyle(theme); + const feet = renderer.feet; - renderer.feet.forEach((footElement: HTMLElement, index: number) => { + feet.forEach((footElement: HTMLElement, index: number) => { if (footElement) { - const footerContent = this.createFooterContent(pageInfo, isSingleColumn, index, renderer.feet.length, footerStyle, timeRemainingLabel); + const footerContent = this.createFooterContent(pageInfo, isSingleColumn, index, feet.length, footerStyle, timeRemainingLabel); footElement.replaceChildren(footerContent); } }); diff --git a/frontend/src/app/features/readers/ebook-reader/shared/selection-popup.component.ts b/frontend/src/app/features/readers/ebook-reader/shared/selection-popup.component.ts index 9410e5c3f..842c4616e 100644 --- a/frontend/src/app/features/readers/ebook-reader/shared/selection-popup.component.ts +++ b/frontend/src/app/features/readers/ebook-reader/shared/selection-popup.component.ts @@ -128,7 +128,7 @@ export class TextSelectionPopupComponent { this.hasPreview = false; } - onDismiss(event: MouseEvent): void { + onDismiss(event: Event): void { event.stopPropagation(); event.preventDefault(); diff --git a/frontend/src/app/features/readers/ebook-reader/state/progress.service.ts b/frontend/src/app/features/readers/ebook-reader/state/progress.service.ts index 5eb1b2272..7ca0da891 100644 --- a/frontend/src/app/features/readers/ebook-reader/state/progress.service.ts +++ b/frontend/src/app/features/readers/ebook-reader/state/progress.service.ts @@ -108,7 +108,7 @@ export class ReaderProgressService { } if (cfi && percentage !== null) { - this.bookPatchService.saveEpubProgress(this.bookId, cfi, href, percentage, this.bookFileId); + this.bookPatchService.saveEpubProgress(this.bookId, cfi, href ?? '', percentage, this.bookFileId); this.readingSessionService.updateProgress(cfi, percentage); } @@ -123,7 +123,7 @@ export class ReaderProgressService { } if (detail?.section) { - const percentCompleted = Math.round((detail.fraction * 100) * 10) / 10; + const percentCompleted = Math.round(((detail.fraction ?? 0) * 100) * 10) / 10; const totalMinutes = detail.time?.section ?? 0; const hours = Math.floor(totalMinutes / 60); diff --git a/frontend/src/app/features/series-browser/components/series-card/series-card.component.ts b/frontend/src/app/features/series-browser/components/series-card/series-card.component.ts index 2a48f6180..2cd4443cf 100644 --- a/frontend/src/app/features/series-browser/components/series-card/series-card.component.ts +++ b/frontend/src/app/features/series-browser/components/series-card/series-card.component.ts @@ -43,7 +43,7 @@ export class SeriesCardComponent { : this.urlHelper.getThumbnailUrl(book.id, book.metadata?.coverUpdatedOn); } - onCardClick(event: MouseEvent): void { + onCardClick(event: Event): void { event.stopPropagation(); this.cardClick.emit(this.series); } diff --git a/frontend/src/app/features/settings/reader-preferences/epub-reader-preferences/epub-reader-preferences-component.ts b/frontend/src/app/features/settings/reader-preferences/epub-reader-preferences/epub-reader-preferences-component.ts index e627f6060..f764a7afe 100644 --- a/frontend/src/app/features/settings/reader-preferences/epub-reader-preferences/epub-reader-preferences-component.ts +++ b/frontend/src/app/features/settings/reader-preferences/epub-reader-preferences/epub-reader-preferences-component.ts @@ -122,14 +122,14 @@ export class EpubReaderPreferencesComponent implements OnDestroy { } get selectedFont(): string | null { - return this.userSettings.ebookReaderSetting.fontFamily; + return this.userSettings.ebookReaderSetting.fontFamily || null; } set selectedFont(value: string | null) { if (typeof value === "string") { this.userSettings.ebookReaderSetting.fontFamily = value; } else { - this.userSettings.ebookReaderSetting.fontFamily = null; + this.userSettings.ebookReaderSetting.fontFamily = ''; } this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'fontFamily'], value); } diff --git a/frontend/src/app/features/settings/reader-preferences/reader-preferences.service.ts b/frontend/src/app/features/settings/reader-preferences/reader-preferences.service.ts index 5fc1a5712..f7b3a0f8b 100644 --- a/frontend/src/app/features/settings/reader-preferences/reader-preferences.service.ts +++ b/frontend/src/app/features/settings/reader-preferences/reader-preferences.service.ts @@ -24,7 +24,7 @@ export class ReaderPreferencesService { updatePreference(path: string[], value: unknown): void { if (!this.currentUser) return; - let target = this.currentUser.userSettings as MutableSettingsBranch; + let target = this.currentUser.userSettings as unknown as MutableSettingsBranch; for (let i = 0; i < path.length - 1; i++) { const next = target[path[i]]; if (!next || typeof next !== 'object') { diff --git a/frontend/src/app/features/settings/view-preferences-parent/filter-preferences/filter-preferences.component.ts b/frontend/src/app/features/settings/view-preferences-parent/filter-preferences/filter-preferences.component.ts index c3e9395f3..91726bc11 100644 --- a/frontend/src/app/features/settings/view-preferences-parent/filter-preferences/filter-preferences.component.ts +++ b/frontend/src/app/features/settings/view-preferences-parent/filter-preferences/filter-preferences.component.ts @@ -72,7 +72,7 @@ export class FilterPreferencesComponent { private updatePreference(path: string[], value: unknown): void { if (!this.currentUser) return; - let target = this.currentUser.userSettings as MutableSettingsBranch; + let target = this.currentUser.userSettings as unknown as MutableSettingsBranch; for (let i = 0; i < path.length - 1; i++) { const next = target[path[i]]; if (!next || typeof next !== 'object') { diff --git a/frontend/src/app/features/settings/view-preferences-parent/sidebar-sorting-preferences/sidebar-sorting-preferences.component.ts b/frontend/src/app/features/settings/view-preferences-parent/sidebar-sorting-preferences/sidebar-sorting-preferences.component.ts index 77eaaac6a..4384f8b8b 100644 --- a/frontend/src/app/features/settings/view-preferences-parent/sidebar-sorting-preferences/sidebar-sorting-preferences.component.ts +++ b/frontend/src/app/features/settings/view-preferences-parent/sidebar-sorting-preferences/sidebar-sorting-preferences.component.ts @@ -78,7 +78,7 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy { private updatePreference(path: string[], value: unknown): void { if (!this.currentUser) return; - let target = this.currentUser.userSettings as MutableSettingsBranch; + let target = this.currentUser.userSettings as unknown as MutableSettingsBranch; for (let i = 0; i < path.length - 1; i++) { const next = target[path[i]]; if (!next || typeof next !== 'object') { diff --git a/frontend/src/app/features/stats/component/user-stats/charts/reading-debt-chart/reading-debt-chart.component.ts b/frontend/src/app/features/stats/component/user-stats/charts/reading-debt-chart/reading-debt-chart.component.ts index 7d2962123..735cec231 100644 --- a/frontend/src/app/features/stats/component/user-stats/charts/reading-debt-chart/reading-debt-chart.component.ts +++ b/frontend/src/app/features/stats/component/user-stats/charts/reading-debt-chart/reading-debt-chart.component.ts @@ -6,8 +6,6 @@ import {ChartConfiguration, ChartData} from 'chart.js'; import {BookService} from '../../../../../book/service/book.service'; import {TranslocoDirective, TranslocoService} from '@jsverse/transloco'; -type ReadingDebtChartData = ChartData<'bar' | 'line', number[], string>; - @Component({ selector: 'app-reading-debt-chart', standalone: true, @@ -31,7 +29,7 @@ export class ReadingDebtChartComponent { public currentBacklog = 0; public trend = ''; - public chartData: ReadingDebtChartData = {labels: [], datasets: []}; + public chartData: ChartData<'bar', number[], string> = {labels: [], datasets: []}; public chartOptions: ChartConfiguration<'bar'>['options'] = { responsive: true, @@ -159,7 +157,7 @@ export class ReadingDebtChartComponent { tension: 0.3, yAxisID: 'y1', order: 1 - } as ReadingDebtChartData['datasets'][number] + } as unknown as ChartData<'bar', number[], string>['datasets'][number] ] }; this.hasData = true; diff --git a/frontend/src/app/shared/layout/component/layout-menu/app.menuitem.component.ts b/frontend/src/app/shared/layout/component/layout-menu/app.menuitem.component.ts index 8b67ed481..d8df2f8db 100644 --- a/frontend/src/app/shared/layout/component/layout-menu/app.menuitem.component.ts +++ b/frontend/src/app/shared/layout/component/layout-menu/app.menuitem.component.ts @@ -15,12 +15,28 @@ import {IconDisplayComponent} from '../../../components/icon-display/icon-displa import {Tooltip} from 'primeng/tooltip'; import {IconSelection} from '../../../service/icon-picker.service'; import {TranslocoPipe} from '@jsverse/transloco'; +import {MenuItem, MenuItemCommandEvent} from 'primeng/api'; -type AppMenuItem = MenuItem & { +type AppMenuItem = Omit & { items?: AppMenuItem[]; + label?: string; routerLink?: string[]; + queryParams?: MenuItem['queryParams']; + queryParamsHandling?: MenuItem['queryParamsHandling']; + fragment?: string; + preserveFragment?: boolean; + skipLocationChange?: boolean; + replaceUrl?: boolean; + state?: MenuItem['state']; + target?: string; type?: 'library' | 'magicShelf' | 'shelf' | string; - iconType?: string; + iconType?: IconSelection['type']; + icon?: string; + disabled?: boolean; + command?: (event: MenuItemCommandEvent) => void; + class?: string; + menu?: MenuItem[]; + badgeClass?: string; unhealthy?: boolean; bookCount?: number; hasDropDown?: boolean; @@ -143,7 +159,12 @@ export class AppMenuitemComponent implements OnInit, OnDestroy { } updateActiveStateFromRoute() { - const activeRoute = this.router.isActive(this.item.routerLink[0], { + const firstRoute = this.item.routerLink?.[0]; + if (!firstRoute) { + return; + } + + const activeRoute = this.router.isActive(firstRoute, { paths: 'exact', queryParams: 'ignored', matrixParams: 'ignored', diff --git a/frontend/src/app/shared/websocket/rx-stomp-service-factory.ts b/frontend/src/app/shared/websocket/rx-stomp-service-factory.ts index f99ca8ab6..41e334d35 100644 --- a/frontend/src/app/shared/websocket/rx-stomp-service-factory.ts +++ b/frontend/src/app/shared/websocket/rx-stomp-service-factory.ts @@ -3,7 +3,8 @@ import { createRxStompConfig } from './rx-stomp.config'; import {AuthService} from '../service/auth.service'; export function rxStompServiceFactory(authService: AuthService) { - const rxStomp = new RxStompService(authService); + void authService; + const rxStomp = new RxStompService(); const stompConfig = createRxStompConfig(authService); rxStomp.configure(stompConfig); return rxStomp;