diff --git a/booklore-ui/src/app/features/book/components/book-browser/book-browser.component.ts b/booklore-ui/src/app/features/book/components/book-browser/book-browser.component.ts index 280d9cfaa..34481c8c0 100644 --- a/booklore-ui/src/app/features/book/components/book-browser/book-browser.component.ts +++ b/booklore-ui/src/app/features/book/components/book-browser/book-browser.component.ts @@ -5,7 +5,7 @@ import {PageTitleService} from "../../../../shared/service/page-title.service"; import {LibraryService} from '../../service/library.service'; import {BookService} from '../../service/book.service'; import {catchError, debounceTime, filter, map, switchMap, take} from 'rxjs/operators'; -import {BehaviorSubject, combineLatest, finalize, forkJoin, Observable, of, Subject} from 'rxjs'; +import {BehaviorSubject, combineLatest, finalize, Observable, of, Subject} from 'rxjs'; import {ShelfService} from '../../service/shelf.service'; import {DynamicDialogRef} from 'primeng/dynamicdialog'; import {Library} from '../../model/library.model'; @@ -129,7 +129,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { entityType$: Observable | undefined; searchTerm$ = new BehaviorSubject(''); parsedFilters: Record = {}; - selectedFilter = new BehaviorSubject | null>(null); + selectedFilter = new BehaviorSubject | null>(null); selectedFilterMode = new BehaviorSubject('and'); protected resetFilterSubject = new Subject(); entity: Library | Shelf | MagicShelf | null = null; @@ -272,7 +272,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { this.activatedRoute.paramMap, this.activatedRoute.queryParamMap, this.userService.userState$.pipe(filter(u => !!u?.user && u.loaded)) - ]).subscribe(([paramMap, queryParamMap, user]) => { + ]).subscribe(([_, queryParamMap, user]) => { const viewParam = queryParamMap.get(QUERY_PARAMS.VIEW); const sortParam = queryParamMap.get(QUERY_PARAMS.SORT); @@ -281,9 +281,9 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { const filterMode = queryParamMap.get(QUERY_PARAMS.FMODE) || user.user?.userSettings?.filterMode; if (filterMode && filterMode !== this.selectedFilterMode.getValue()) { - this.selectedFilterMode.next(filterMode); + this.selectedFilterMode.next((filterMode as BookFilterMode)); if (this.bookFilterComponent) { - this.bookFilterComponent.selectedFilterMode = filterMode; + this.bookFilterComponent.selectedFilterMode = filterMode as BookFilterMode; } } @@ -379,7 +379,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { this.applySortOption(this.bookSorter.selectedSort); } - const queryParams: any = { + const queryParams: Record = { [QUERY_PARAMS.VIEW]: this.currentViewMode, [QUERY_PARAMS.SORT]: this.bookSorter.selectedSort.field, [QUERY_PARAMS.DIRECTION]: this.bookSorter.selectedSort.direction === SortDirection.ASCENDING ? SORT_DIRECTION.ASCENDING : SORT_DIRECTION.DESCENDING, @@ -465,7 +465,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { this.coverScalePreferenceService.setScale(this.coverScalePreferenceService.scaleFactor); } - onVisibleColumnsChange(selected: any[]) { + onVisibleColumnsChange(selected: { field: string; header: string }[]) { const allFields = this.bookTableComponent.allColumns.map(col => col.field); this.visibleColumns = selected.sort( (a, b) => allFields.indexOf(a.field) - allFields.indexOf(b.field) @@ -556,8 +556,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { .subscribe(() => { this.selectedBooks.clear(); }); - }, - reject: () => { } }); } @@ -754,8 +752,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { return (entity as Library).paths !== undefined; } - private isMagicShelf(entity: any): entity is MagicShelf { - return entity && 'filterJson' in entity; + private isMagicShelf(entity: Library | Shelf | MagicShelf | null): entity is MagicShelf { + return !!entity && 'filterJson' in entity; } private getEntityInfoFromRoute(): Observable<{ entityId: number; entityType: EntityType }> { diff --git a/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.ts b/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.ts index 06200a3de..e36cf49ad 100644 --- a/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.ts +++ b/booklore-ui/src/app/features/book/components/book-browser/book-filter/book-filter.component.ts @@ -125,7 +125,7 @@ function extractPublishedYearFilter(book: Book): { id: string; name: string }[] } function getShelfStatusFilter(book: Book): { id: string; name: string }[] { - const isShelved = book.shelves?.length! > 0; + const isShelved = (book.shelves?.length ?? 0) > 0; return [{id: isShelved ? 'shelved' : 'unshelved', name: isShelved ? 'Shelved' : 'Unshelved'}]; } @@ -285,10 +285,10 @@ export class BookFilterComponent implements OnInit, OnDestroy { bookType: this.getFilterStream(getBookTypeFilter, 'id', 'name'), shelfStatus: this.getFilterStream(getShelfStatusFilter, 'id', 'name'), fileSize: this.getFilterStream((book: Book) => getFileSizeRangeFilters(book.fileSizeKb), 'id', 'name', 'sortIndex'), - pageCount: this.getFilterStream((book: Book) => getPageCountRangeFilters(book.metadata?.pageCount!), 'id', 'name', 'sortIndex'), - amazonRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.amazonRating!), 'id', 'name', 'sortIndex'), - goodreadsRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.goodreadsRating!), 'id', 'name', 'sortIndex'), - hardcoverRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.hardcoverRating!), 'id', 'name', 'sortIndex'), + pageCount: this.getFilterStream((book: Book) => getPageCountRangeFilters(book.metadata?.pageCount ?? undefined), 'id', 'name', 'sortIndex'), + amazonRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.amazonRating ?? undefined), 'id', 'name', 'sortIndex'), + goodreadsRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.goodreadsRating ?? undefined), 'id', 'name', 'sortIndex'), + hardcoverRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.hardcoverRating ?? undefined), 'id', 'name', 'sortIndex'), }; this.filterTypes = Object.keys(this.filterStreams) as FilterType[]; @@ -469,18 +469,18 @@ export class BookFilterComponent implements OnInit, OnDestroy { trackByFilter(_: number, filter: Filter): unknown { const value = filter.value as { id?: unknown } | unknown; - return (typeof value === 'object' && value !== null && 'id' in value) ? (value as any).id : filter.value; + return (typeof value === 'object' && value !== null && 'id' in value) ? (value as {id: unknown}).id : filter.value; } getFilterValueId(filter: Filter): unknown { const value = filter.value as { id?: unknown } | unknown; - return (typeof value === 'object' && value !== null && 'id' in value) ? (value as any).id : filter.value; + return (typeof value === 'object' && value !== null && 'id' in value) ? (value as {id: unknown}).id : filter.value; } getFilterValueDisplay(filter: Filter): string { const value = filter.value as { name?: string } | string | unknown; if (typeof value === 'object' && value !== null && 'name' in value) { - return String((value as any).name ?? ''); + return String((value as {name: string}).name ?? ''); } return String(value ?? ''); } diff --git a/booklore-ui/src/app/features/book/components/book-browser/book-table/book-table.component.ts b/booklore-ui/src/app/features/book/components/book-browser/book-table/book-table.component.ts index 6b9927863..f9dd09d1f 100644 --- a/booklore-ui/src/app/features/book/components/book-browser/book-table/book-table.component.ts +++ b/booklore-ui/src/app/features/book/components/book-browser/book-table/book-table.component.ts @@ -10,7 +10,7 @@ import {UrlHelperService} from '../../../../../shared/service/url-helper.service import {Button} from 'primeng/button'; import {BookService} from '../../../service/book.service'; import {MessageService} from 'primeng/api'; -import {Router, RouterLink} from '@angular/router'; +import {RouterLink} from '@angular/router'; import {filter, Subject} from 'rxjs'; import {UserService} from '../../../../settings/user-management/user.service'; import {take, takeUntil} from 'rxjs/operators'; diff --git a/booklore-ui/src/app/features/book/components/series-page/series-page.component.ts b/booklore-ui/src/app/features/book/components/series-page/series-page.component.ts index a25fae526..93df73156 100644 --- a/booklore-ui/src/app/features/book/components/series-page/series-page.component.ts +++ b/booklore-ui/src/app/features/book/components/series-page/series-page.component.ts @@ -1,4 +1,3 @@ -import { Component, inject, OnDestroy } from "@angular/core"; import { FormsModule } from "@angular/forms"; import { Button } from "primeng/button"; import { ActivatedRoute } from "@angular/router"; diff --git a/booklore-ui/src/app/features/book/components/shelf-creator/shelf-creator.component.html b/booklore-ui/src/app/features/book/components/shelf-creator/shelf-creator.component.html index 6d21d6d0e..88509d0ab 100644 --- a/booklore-ui/src/app/features/book/components/shelf-creator/shelf-creator.component.html +++ b/booklore-ui/src/app/features/book/components/shelf-creator/shelf-creator.component.html @@ -34,7 +34,7 @@ class="input-full" placeholder="e.g., Favorites, To Read, Currently Reading" [class.filled]="shelfName.trim()" - autofocus + /> @if (shelfName.trim()) { diff --git a/booklore-ui/src/app/features/book/service/library-shelf-menu.service.ts b/booklore-ui/src/app/features/book/service/library-shelf-menu.service.ts index 2bc8a4dca..7c8759ede 100644 --- a/booklore-ui/src/app/features/book/service/library-shelf-menu.service.ts +++ b/booklore-ui/src/app/features/book/service/library-shelf-menu.service.ts @@ -38,7 +38,7 @@ export class LibraryShelfMenuService { label: 'Edit Library', icon: 'pi pi-pen-to-square', command: () => { - this.dialogLauncherService.openLibraryEditDialog(entity?.id); + this.dialogLauncherService.openLibraryEditDialog((entity?.id as number)); } }, { @@ -77,7 +77,7 @@ export class LibraryShelfMenuService { label: 'Custom Fetch Metadata', icon: 'pi pi-sync', command: () => { - this.dialogLauncherService.openLibraryMetadataFetchDialog(entity?.id); + this.dialogLauncherService.openLibraryMetadataFetchDialog((entity?.id as number)); } }, { @@ -144,7 +144,7 @@ export class LibraryShelfMenuService { label: 'Edit Shelf', icon: 'pi pi-pen-to-square', command: () => { - this.dialogLauncherService.openShelfEditDialog(entity?.id); + this.dialogLauncherService.openShelfEditDialog((entity?.id as number)); } }, { @@ -197,7 +197,7 @@ export class LibraryShelfMenuService { icon: 'pi pi-pen-to-square', disabled: disableOptions, command: () => { - this.dialogLauncherService.openMagicShelfEditDialog(entity?.id); + this.dialogLauncherService.openMagicShelfEditDialog((entity?.id as number)); } }, { diff --git a/booklore-ui/src/app/features/bookdrop/component/bookdrop-pattern-extract-dialog/bookdrop-pattern-extract-dialog.component.ts b/booklore-ui/src/app/features/bookdrop/component/bookdrop-pattern-extract-dialog/bookdrop-pattern-extract-dialog.component.ts index 089dd0aa5..509de563f 100644 --- a/booklore-ui/src/app/features/bookdrop/component/bookdrop-pattern-extract-dialog/bookdrop-pattern-extract-dialog.component.ts +++ b/booklore-ui/src/app/features/bookdrop/component/bookdrop-pattern-extract-dialog/bookdrop-pattern-extract-dialog.component.ts @@ -267,7 +267,7 @@ export class BookdropPatternExtractDialogComponent implements OnInit { return preview.success ? 'pi-check-circle' : 'pi-times-circle'; } - getPreviewEntries(preview: PreviewResult): Array<{key: string; value: string}> { + getPreviewEntries(preview: PreviewResult): {key: string; value: string}[] { return Object.entries(preview.preview).map(([key, value]) => ({key, value})); } diff --git a/booklore-ui/src/app/features/dashboard/components/main-dashboard/main-dashboard.component.ts b/booklore-ui/src/app/features/dashboard/components/main-dashboard/main-dashboard.component.ts index 74d29a4a7..dc23d43fd 100644 --- a/booklore-ui/src/app/features/dashboard/components/main-dashboard/main-dashboard.component.ts +++ b/booklore-ui/src/app/features/dashboard/components/main-dashboard/main-dashboard.component.ts @@ -137,7 +137,7 @@ export class MainDashboardComponent implements OnInit { return this.bookService.bookState$.pipe( map((state: BookState) => { - let filteredBooks = (state.books || []).filter((book) => + const filteredBooks = (state.books || []).filter((book) => this.ruleEvaluatorService.evaluateGroup(book, group) ); diff --git a/booklore-ui/src/app/features/library-creator/library-creator.component.ts b/booklore-ui/src/app/features/library-creator/library-creator.component.ts index b260b3f5a..d0b4773dd 100644 --- a/booklore-ui/src/app/features/library-creator/library-creator.component.ts +++ b/booklore-ui/src/app/features/library-creator/library-creator.component.ts @@ -128,9 +128,9 @@ export class LibraryCreatorComponent implements OnInit { } validateLibraryNameAndProceed(activateCallback: Function): void { - let trimmedLibraryName = this.chosenLibraryName.trim(); + const trimmedLibraryName = this.chosenLibraryName.trim(); if (trimmedLibraryName && trimmedLibraryName != this.editModeLibraryName) { - let exists = this.libraryService.doesLibraryExistByName(trimmedLibraryName); + const exists = this.libraryService.doesLibraryExistByName(trimmedLibraryName); if (exists) { this.messageService.add({ severity: 'error', diff --git a/booklore-ui/src/app/features/magic-shelf/component/magic-shelf-component.ts b/booklore-ui/src/app/features/magic-shelf/component/magic-shelf-component.ts index 3b66215ff..c32b9bee3 100644 --- a/booklore-ui/src/app/features/magic-shelf/component/magic-shelf-component.ts +++ b/booklore-ui/src/app/features/magic-shelf/component/magic-shelf-component.ts @@ -383,7 +383,7 @@ export class MagicShelfComponent implements OnInit { createGroup(): GroupFormGroup { return new FormGroup({ - type: new FormControl<'group'>('group' as 'group'), + type: new FormControl<'group'>('group' as const), join: new FormControl<'and' | 'or'>('and' as 'and' | 'or'), rules: new FormArray([] as (GroupFormGroup | RuleFormGroup)[]), }) as GroupFormGroup; diff --git a/booklore-ui/src/app/features/metadata/component/book-metadata-center/book-reading-sessions/book-reading-sessions.component.ts b/booklore-ui/src/app/features/metadata/component/book-metadata-center/book-reading-sessions/book-reading-sessions.component.ts index 44dee40c9..6b3fc274e 100644 --- a/booklore-ui/src/app/features/metadata/component/book-metadata-center/book-reading-sessions/book-reading-sessions.component.ts +++ b/booklore-ui/src/app/features/metadata/component/book-metadata-center/book-reading-sessions/book-reading-sessions.component.ts @@ -1,4 +1,4 @@ -import {Component, inject, Input, OnInit, OnChanges, SimpleChanges} from '@angular/core'; +import {Component, inject, Input, OnInit, OnChanges, SimpleChanges, ChangeDetectorRef} from '@angular/core'; import {CommonModule} from '@angular/common'; import {ReadingSessionApiService, ReadingSessionResponse} from '../../../../../shared/service/reading-session-api.service'; import {TableModule} from 'primeng/table'; @@ -16,6 +16,7 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges { @Input() bookId!: number; private readonly readingSessionService = inject(ReadingSessionApiService); + private readonly cdr = inject(ChangeDetectorRef); sessions: ReadingSessionResponse[] = []; totalRecords = 0; @@ -24,7 +25,7 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges { loading = false; ngOnInit() { - this.loadSessions(); + // Rely on p-table onLazyLoad to trigger the initial load } ngOnChanges(changes: SimpleChanges) { @@ -35,16 +36,23 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges { } loadSessions(page: number = 0) { - this.loading = true; + // Prevent ExpressionChangedAfterItHasBeenCheckedError + setTimeout(() => { + this.loading = true; + this.cdr.markForCheck(); + }); + this.readingSessionService.getSessionsByBookId(this.bookId, page, this.rows) .subscribe({ next: (response) => { this.sessions = response.content; this.totalRecords = response.totalElements; this.loading = false; + this.cdr.markForCheck(); }, error: () => { this.loading = false; + this.cdr.markForCheck(); } }); } diff --git a/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-editor/metadata-editor.component.ts b/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-editor/metadata-editor.component.ts index 46480d161..aef0fb988 100644 --- a/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-editor/metadata-editor.component.ts +++ b/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-editor/metadata-editor.component.ts @@ -600,7 +600,7 @@ export class MetadataEditorComponent implements OnInit { } private updateMetadata(shouldLockAllFields: boolean | undefined): void { - let metadataUpdateWrapper = this.buildMetadataWrapper(shouldLockAllFields); + const metadataUpdateWrapper = this.buildMetadataWrapper(shouldLockAllFields); this.bookService .updateBookMetadata(this.currentBookId, metadataUpdateWrapper, false) .subscribe({ diff --git a/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-picker/metadata-picker.component.ts b/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-picker/metadata-picker.component.ts index 2adc8b703..d6b938cb4 100644 --- a/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-picker/metadata-picker.component.ts +++ b/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-picker/metadata-picker.component.ts @@ -677,7 +677,7 @@ export class MetadataPickerComponent implements OnInit { this.goBack.emit(true); } - hoveredFields: { [key: string]: boolean } = {}; + hoveredFields: Record = {}; onMouseEnter(controlName: string): void { if (this.isValueCopied(controlName) && !this.isValueSaved(controlName)) { diff --git a/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-viewer/metadata-viewer.component.ts b/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-viewer/metadata-viewer.component.ts index 724d2d8fd..6ced45fc3 100644 --- a/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-viewer/metadata-viewer.component.ts +++ b/booklore-ui/src/app/features/metadata/component/book-metadata-center/metadata-viewer/metadata-viewer.component.ts @@ -439,7 +439,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges { } assignShelf(bookId: number) { - this.bookDialogHelperService.openShelfAssignerDialog(this.bookService.getBookByIdFromState(bookId), null); + this.bookDialogHelperService.openShelfAssignerDialog((this.bookService.getBookByIdFromState(bookId) as Book), null); } updateReadStatus(status: ReadStatus): void { diff --git a/booklore-ui/src/app/features/metadata/component/cover-search/cover-search.component.ts b/booklore-ui/src/app/features/metadata/component/cover-search/cover-search.component.ts index 641a9ebbc..e78e19c02 100644 --- a/booklore-ui/src/app/features/metadata/component/cover-search/cover-search.component.ts +++ b/booklore-ui/src/app/features/metadata/component/cover-search/cover-search.component.ts @@ -47,7 +47,7 @@ export class CoverSearchComponent implements OnInit { ngOnInit() { this.bookId = this.dynamicDialogConfig.data.bookId; - let book = this.bookService.getBookByIdFromState(this.bookId); + const book = this.bookService.getBookByIdFromState(this.bookId); if (book) { this.searchForm.patchValue({ diff --git a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts index f7618820e..65725d73c 100644 --- a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts +++ b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts @@ -257,6 +257,11 @@ export class EpubReaderComponent implements OnInit, OnDestroy { const cfi = this.rendition.currentLocation()?.start?.cfi; const locations = this.book.locations.save(); + if (this.rendition) { + this.rendition.destroy(); + this.rendition = null; + } + this.initBook(locations); this.initRendition(cfi); this.updateViewerSetting(); @@ -268,6 +273,11 @@ export class EpubReaderComponent implements OnInit, OnDestroy { const cfi = this.rendition.currentLocation()?.start?.cfi; const locations = this.book.locations.save(); + if (this.rendition) { + this.rendition.destroy(); + this.rendition = null; + } + this.initBook(locations); this.initRendition(cfi); this.updateViewerSetting(); @@ -829,7 +839,23 @@ export class EpubReaderComponent implements OnInit, OnDestroy { if (this.rendition) { this.rendition.off('keyup', this.keyListener); + try { + this.rendition.destroy(); + } catch (e) { + console.warn('Error destroying rendition in ngOnDestroy', e); + } + this.rendition = null; } + + if (this.book) { + try { + this.book.destroy(); + } catch (e) { + console.warn('Error destroying book in ngOnDestroy', e); + } + this.book = null; + } + document.removeEventListener('keyup', this.keyListener); if (this.hideControlsTimeout) { diff --git a/booklore-ui/src/app/features/readers/epub-reader/epub-reader-helper.ts b/booklore-ui/src/app/features/readers/epub-reader/epub-reader-helper.ts index 0d0a3d192..bf1e36654 100644 --- a/booklore-ui/src/app/features/readers/epub-reader/epub-reader-helper.ts +++ b/booklore-ui/src/app/features/readers/epub-reader/epub-reader-helper.ts @@ -15,13 +15,13 @@ export function getCfiFromHref(book: Book, href: string): string | null { const section = book.spine.get(href); if (!section || !section.document) { - console.warn('Section or section.document is undefined for href:', href); + console.debug('Section or section.document is undefined for href:', href); return null; } const el = id ? section.document.getElementById(id) : section.document.body; if (!el) { - console.warn('Element not found in section.document for href:', href); + console.debug('Element not found in section.document for href:', href); return null; } diff --git a/booklore-ui/src/app/features/settings/email-v2/create-email-provider-dialog/create-email-provider-dialog.component.html b/booklore-ui/src/app/features/settings/email-v2/create-email-provider-dialog/create-email-provider-dialog.component.html index 91704709f..e90c87080 100644 --- a/booklore-ui/src/app/features/settings/email-v2/create-email-provider-dialog/create-email-provider-dialog.component.html +++ b/booklore-ui/src/app/features/settings/email-v2/create-email-provider-dialog/create-email-provider-dialog.component.html @@ -35,7 +35,7 @@ class="input-full" placeholder="e.g., Gmail SMTP, SendGrid" [class.filled]="emailProviderForm.get('name')?.value" - autofocus + /> @if (emailProviderForm.get('name')?.value && emailProviderForm.get('name')?.valid) { diff --git a/booklore-ui/src/app/features/settings/email-v2/create-email-recipient-dialog/create-email-recipient-dialog.component.html b/booklore-ui/src/app/features/settings/email-v2/create-email-recipient-dialog/create-email-recipient-dialog.component.html index c3c8bf978..bcb823350 100644 --- a/booklore-ui/src/app/features/settings/email-v2/create-email-recipient-dialog/create-email-recipient-dialog.component.html +++ b/booklore-ui/src/app/features/settings/email-v2/create-email-recipient-dialog/create-email-recipient-dialog.component.html @@ -35,7 +35,7 @@ class="input-full" placeholder="Enter recipient name..." [class.filled]="emailRecipientForm.get('name')?.value" - autofocus + /> @if (emailRecipientForm.get('name')?.value && emailRecipientForm.get('name')?.valid) { diff --git a/booklore-ui/src/app/features/settings/library-metadata-settings/library-metadata-settings.component.ts b/booklore-ui/src/app/features/settings/library-metadata-settings/library-metadata-settings.component.ts index fb37d1037..3672182a9 100644 --- a/booklore-ui/src/app/features/settings/library-metadata-settings/library-metadata-settings.component.ts +++ b/booklore-ui/src/app/features/settings/library-metadata-settings/library-metadata-settings.component.ts @@ -31,7 +31,7 @@ export class LibraryMetadataSettingsComponent implements OnInit { ); defaultMetadataOptions: MetadataRefreshOptions = this.getDefaultMetadataOptions(); - libraryMetadataOptions: { [libraryId: number]: MetadataRefreshOptions } = {}; + libraryMetadataOptions: Record = {}; ngOnInit() { this.appSettingsService.appSettings$.subscribe(appSettings => { diff --git a/booklore-ui/src/app/features/settings/reader-preferences/pdf-reader-preferences/pdf-reader-preferences-component.ts b/booklore-ui/src/app/features/settings/reader-preferences/pdf-reader-preferences/pdf-reader-preferences-component.ts index fa6296aa7..2c1b212d0 100644 --- a/booklore-ui/src/app/features/settings/reader-preferences/pdf-reader-preferences/pdf-reader-preferences-component.ts +++ b/booklore-ui/src/app/features/settings/reader-preferences/pdf-reader-preferences/pdf-reader-preferences-component.ts @@ -18,13 +18,13 @@ export class PdfReaderPreferencesComponent { @Input() userSettings!: UserSettings; - readonly spreads: Array<{name: string; key: PageSpread; icon: string}> = [ + readonly spreads: {name: string; key: PageSpread; icon: string}[] = [ {name: 'Even', key: 'even', icon: 'pi pi-align-left'}, {name: 'Odd', key: 'odd', icon: 'pi pi-align-right'}, {name: 'None', key: 'off', icon: 'pi pi-minus'} ]; - readonly zooms: Array<{name: string; key: string; icon: string}> = [ + readonly zooms: {name: string; key: string; icon: string}[] = [ {name: 'Auto Zoom', key: 'auto', icon: 'pi pi-sparkles'}, {name: 'Page Fit', key: 'page-fit', icon: 'pi pi-window-maximize'}, {name: 'Page Width', key: 'page-width', icon: 'pi pi-arrows-h'}, diff --git a/booklore-ui/src/app/features/settings/task-management/task-management.component.ts b/booklore-ui/src/app/features/settings/task-management/task-management.component.ts index e90fcd2a7..468ae9eb4 100644 --- a/booklore-ui/src/app/features/settings/task-management/task-management.component.ts +++ b/booklore-ui/src/app/features/settings/task-management/task-management.component.ts @@ -37,7 +37,7 @@ export class TaskManagementComponent implements OnInit, OnDestroy { // State taskInfos: TaskInfo[] = []; - taskHistories: Map = new Map(); + taskHistories = new Map(); loading = false; executingTasks = new Set(); private subscription?: Subscription; diff --git a/booklore-ui/src/app/features/settings/user-management/user-management.component.ts b/booklore-ui/src/app/features/settings/user-management/user-management.component.ts index ffdc85153..d2ecbdd6a 100644 --- a/booklore-ui/src/app/features/settings/user-management/user-management.component.ts +++ b/booklore-ui/src/app/features/settings/user-management/user-management.component.ts @@ -53,7 +53,7 @@ export class UserManagementComponent implements OnInit, OnDestroy { currentUser: User | null = null; editingLibraryIds: number[] = []; allLibraries: Library[] = []; - expandedRows: { [key: string]: boolean } = {}; + expandedRows: Record = {}; isPasswordDialogVisible = false; selectedUser: User | null = null; diff --git a/booklore-ui/src/app/features/settings/user-management/user-stats.service.ts b/booklore-ui/src/app/features/settings/user-management/user-stats.service.ts index 76fbbc388..914ab920c 100644 --- a/booklore-ui/src/app/features/settings/user-management/user-stats.service.ts +++ b/booklore-ui/src/app/features/settings/user-management/user-stats.service.ts @@ -31,7 +31,7 @@ export interface CompletionTimelineResponse { year: number; month: number; totalBooks: number; - statusBreakdown: { [key: string]: number }; + statusBreakdown: Record; finishedBooks: number; completionRate: number; } @@ -84,7 +84,7 @@ export class UserStatsService { } getFavoriteDays(year?: number, month?: number): Observable { - let params: Record = {}; + const params: Record = {}; if (year !== undefined && year !== null) { params['year'] = year.toString(); } @@ -99,7 +99,7 @@ export class UserStatsService { } getPeakHours(year?: number, month?: number): Observable { - let params: Record = {}; + const params: Record = {}; if (year !== undefined && year !== null) { params['year'] = year.toString(); } diff --git a/booklore-ui/src/app/features/stats/component/reading-session-heatmap/reading-session-heatmap.component.ts b/booklore-ui/src/app/features/stats/component/reading-session-heatmap/reading-session-heatmap.component.ts index d189da9bd..1e7602365 100644 --- a/booklore-ui/src/app/features/stats/component/reading-session-heatmap/reading-session-heatmap.component.ts +++ b/booklore-ui/src/app/features/stats/component/reading-session-heatmap/reading-session-heatmap.component.ts @@ -174,7 +174,7 @@ export class ReadingSessionHeatmapComponent implements OnInit, OnDestroy { firstMonday.setDate(firstMonday.getDate() - daysToMonday); let weekIndex = 0; - let currentDate = new Date(firstMonday); + const currentDate = new Date(firstMonday); while (currentDate <= endDate || weekIndex === 0) { for (let dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) { diff --git a/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.ts b/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.ts index 309e287d6..24922278b 100644 --- a/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.ts +++ b/booklore-ui/src/app/shared/components/directory-picker/directory-picker.component.ts @@ -37,7 +37,7 @@ export class DirectoryPickerComponent implements OnInit { filteredPaths: string[] = []; selectedProductName: string = ''; selectedFolders: string[] = []; - selectedFoldersMap: { [key: string]: boolean } = {}; + selectedFoldersMap: Record = {}; searchQuery: string = ''; isLoading: boolean = false; breadcrumbItems: MenuItem[] = []; diff --git a/booklore-ui/src/app/shared/components/file-mover/file-mover-component.ts b/booklore-ui/src/app/shared/components/file-mover/file-mover-component.ts index 52a78b36d..7f1f4c50f 100644 --- a/booklore-ui/src/app/shared/components/file-mover/file-mover-component.ts +++ b/booklore-ui/src/app/shared/components/file-mover/file-mover-component.ts @@ -61,7 +61,7 @@ export class FileMoverComponent implements OnDestroy { loading = false; patternsCollapsed = true; - bookIds: Set = new Set(); + bookIds = new Set(); books: Book[] = []; availableLibraries: { id: number | null; name: string }[] = []; filePreviews: FilePreview[] = []; diff --git a/booklore-ui/src/app/shared/components/metadata-progress-widget/metadata-progress-widget-component.ts b/booklore-ui/src/app/shared/components/metadata-progress-widget/metadata-progress-widget-component.ts index 2a6cd4b6a..e08de2b0a 100644 --- a/booklore-ui/src/app/shared/components/metadata-progress-widget/metadata-progress-widget-component.ts +++ b/booklore-ui/src/app/shared/components/metadata-progress-widget/metadata-progress-widget-component.ts @@ -23,7 +23,7 @@ import {DialogLauncherService} from '../../services/dialog-launcher.service'; imports: [KeyValuePipe, ProgressBarModule, ButtonModule, Divider, Tooltip, Tag] }) export class MetadataProgressWidgetComponent implements OnInit, OnDestroy { - activeTasks: { [taskId: string]: MetadataBatchProgressNotification } = {}; + activeTasks: Record = {}; private destroy$ = new Subject(); private dialogLauncherService = inject(DialogLauncherService); @@ -45,7 +45,7 @@ export class MetadataProgressWidgetComponent implements OnInit, OnDestroy { }); } - private checkForStalledTasks(tasks: { [taskId: string]: MetadataBatchProgressNotification }): void { + private checkForStalledTasks(tasks: Record): void { const now = Date.now(); for (const taskId of this.timeoutHandles.keys()) { diff --git a/booklore-ui/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts b/booklore-ui/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts index 41022086e..a87cbbd40 100644 --- a/booklore-ui/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts +++ b/booklore-ui/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts @@ -71,7 +71,7 @@ export class AppTopBarComponent implements OnDestroy { private eventTimer: number | undefined; private destroy$ = new Subject(); - private latestTasks: { [taskId: string]: MetadataBatchProgressNotification } = {}; + private latestTasks: Record = {}; private latestHasPendingFiles = false; private latestNotificationSeverity?: Severity; @@ -206,7 +206,7 @@ export class AppTopBarComponent implements OnDestroy { this.completedTaskCount = completedMetadataTasks + bookdropFileTaskCount; } - private updateTaskVisibility(tasks: { [taskId: string]: MetadataBatchProgressNotification }) { + private updateTaskVisibility(tasks: Record) { this.hasActiveOrCompletedTasks = this.progressHighlight || this.completedTaskCount > 0 || Object.keys(tasks).length > 0; this.updateTaskVisibilityWithBookdrop(); diff --git a/booklore-ui/src/app/shared/service/metadata-progress.service.ts b/booklore-ui/src/app/shared/service/metadata-progress.service.ts index 7e2215544..b6a9d1ba9 100644 --- a/booklore-ui/src/app/shared/service/metadata-progress.service.ts +++ b/booklore-ui/src/app/shared/service/metadata-progress.service.ts @@ -12,7 +12,7 @@ export class MetadataProgressService implements OnDestroy { private progressUpdatesSubject = new Subject(); progressUpdates$ = this.progressUpdatesSubject.asObservable(); - private activeTasksSubject = new BehaviorSubject<{ [taskId: string]: MetadataBatchProgressNotification }>({}); + private activeTasksSubject = new BehaviorSubject>({}); activeTasks$ = this.activeTasksSubject.asObservable(); private metadataTaskService = inject(MetadataTaskService); @@ -58,8 +58,8 @@ export class MetadataProgressService implements OnDestroy { this.activeTasksSubject.next(this.getActiveTasks()); } - getActiveTasks(): { [taskId: string]: MetadataBatchProgressNotification } { - const result: { [taskId: string]: MetadataBatchProgressNotification } = {}; + getActiveTasks(): Record { + const result: Record = {}; this.progressMap.forEach((subject, taskId) => { result[taskId] = subject.getValue(); }); diff --git a/booklore-ui/src/app/shared/services/icon.service.ts b/booklore-ui/src/app/shared/services/icon.service.ts index 54d4b1a25..53bd9d2d8 100644 --- a/booklore-ui/src/app/shared/services/icon.service.ts +++ b/booklore-ui/src/app/shared/services/icon.service.ts @@ -24,9 +24,7 @@ interface SvgIconBatchResponse { results: IconSaveResult[]; } -interface IconContentMap { - [iconName: string]: string; -} +type IconContentMap = Record; @Injectable({ providedIn: 'root'