refactor(frontend): resolve linting errors, and EPUB reader lifecycle errors (#2127)
* refactor(types): improve type safety by replacing 'any' with specific types in various components Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * fix(filters): handle undefined values in filter streams and update type for selected filters Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * refactor(epub-reader): improve rendition cleanup and enhance debug logging in helper functions Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * fix(epub-reader): handle errors during rendition and book destruction in ngOnDestroy Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> --------- Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
This commit is contained in:
+9
-11
@@ -5,7 +5,7 @@ import {PageTitleService} from "../../../../shared/service/page-title.service";
|
|||||||
import {LibraryService} from '../../service/library.service';
|
import {LibraryService} from '../../service/library.service';
|
||||||
import {BookService} from '../../service/book.service';
|
import {BookService} from '../../service/book.service';
|
||||||
import {catchError, debounceTime, filter, map, switchMap, take} from 'rxjs/operators';
|
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 {ShelfService} from '../../service/shelf.service';
|
||||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||||
import {Library} from '../../model/library.model';
|
import {Library} from '../../model/library.model';
|
||||||
@@ -129,7 +129,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
|||||||
entityType$: Observable<EntityType> | undefined;
|
entityType$: Observable<EntityType> | undefined;
|
||||||
searchTerm$ = new BehaviorSubject<string>('');
|
searchTerm$ = new BehaviorSubject<string>('');
|
||||||
parsedFilters: Record<string, string[]> = {};
|
parsedFilters: Record<string, string[]> = {};
|
||||||
selectedFilter = new BehaviorSubject<Record<string, any> | null>(null);
|
selectedFilter = new BehaviorSubject<Record<string, string[]> | null>(null);
|
||||||
selectedFilterMode = new BehaviorSubject<BookFilterMode>('and');
|
selectedFilterMode = new BehaviorSubject<BookFilterMode>('and');
|
||||||
protected resetFilterSubject = new Subject<void>();
|
protected resetFilterSubject = new Subject<void>();
|
||||||
entity: Library | Shelf | MagicShelf | null = null;
|
entity: Library | Shelf | MagicShelf | null = null;
|
||||||
@@ -272,7 +272,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
|||||||
this.activatedRoute.paramMap,
|
this.activatedRoute.paramMap,
|
||||||
this.activatedRoute.queryParamMap,
|
this.activatedRoute.queryParamMap,
|
||||||
this.userService.userState$.pipe(filter(u => !!u?.user && u.loaded))
|
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 viewParam = queryParamMap.get(QUERY_PARAMS.VIEW);
|
||||||
const sortParam = queryParamMap.get(QUERY_PARAMS.SORT);
|
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;
|
const filterMode = queryParamMap.get(QUERY_PARAMS.FMODE) || user.user?.userSettings?.filterMode;
|
||||||
|
|
||||||
if (filterMode && filterMode !== this.selectedFilterMode.getValue()) {
|
if (filterMode && filterMode !== this.selectedFilterMode.getValue()) {
|
||||||
this.selectedFilterMode.next(<BookFilterMode>filterMode);
|
this.selectedFilterMode.next((filterMode as BookFilterMode));
|
||||||
if (this.bookFilterComponent) {
|
if (this.bookFilterComponent) {
|
||||||
this.bookFilterComponent.selectedFilterMode = <BookFilterMode>filterMode;
|
this.bookFilterComponent.selectedFilterMode = filterMode as BookFilterMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
|||||||
this.applySortOption(this.bookSorter.selectedSort);
|
this.applySortOption(this.bookSorter.selectedSort);
|
||||||
}
|
}
|
||||||
|
|
||||||
const queryParams: any = {
|
const queryParams: Record<string, string | number | null | undefined> = {
|
||||||
[QUERY_PARAMS.VIEW]: this.currentViewMode,
|
[QUERY_PARAMS.VIEW]: this.currentViewMode,
|
||||||
[QUERY_PARAMS.SORT]: this.bookSorter.selectedSort.field,
|
[QUERY_PARAMS.SORT]: this.bookSorter.selectedSort.field,
|
||||||
[QUERY_PARAMS.DIRECTION]: this.bookSorter.selectedSort.direction === SortDirection.ASCENDING ? SORT_DIRECTION.ASCENDING : SORT_DIRECTION.DESCENDING,
|
[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);
|
this.coverScalePreferenceService.setScale(this.coverScalePreferenceService.scaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleColumnsChange(selected: any[]) {
|
onVisibleColumnsChange(selected: { field: string; header: string }[]) {
|
||||||
const allFields = this.bookTableComponent.allColumns.map(col => col.field);
|
const allFields = this.bookTableComponent.allColumns.map(col => col.field);
|
||||||
this.visibleColumns = selected.sort(
|
this.visibleColumns = selected.sort(
|
||||||
(a, b) => allFields.indexOf(a.field) - allFields.indexOf(b.field)
|
(a, b) => allFields.indexOf(a.field) - allFields.indexOf(b.field)
|
||||||
@@ -556,8 +556,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
|||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.selectedBooks.clear();
|
this.selectedBooks.clear();
|
||||||
});
|
});
|
||||||
},
|
|
||||||
reject: () => {
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -754,8 +752,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
|||||||
return (entity as Library).paths !== undefined;
|
return (entity as Library).paths !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
private isMagicShelf(entity: any): entity is MagicShelf {
|
private isMagicShelf(entity: Library | Shelf | MagicShelf | null): entity is MagicShelf {
|
||||||
return entity && 'filterJson' in entity;
|
return !!entity && 'filterJson' in entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getEntityInfoFromRoute(): Observable<{ entityId: number; entityType: EntityType }> {
|
private getEntityInfoFromRoute(): Observable<{ entityId: number; entityType: EntityType }> {
|
||||||
|
|||||||
+8
-8
@@ -125,7 +125,7 @@ function extractPublishedYearFilter(book: Book): { id: string; name: string }[]
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getShelfStatusFilter(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'}];
|
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'),
|
bookType: this.getFilterStream(getBookTypeFilter, 'id', 'name'),
|
||||||
shelfStatus: this.getFilterStream(getShelfStatusFilter, 'id', 'name'),
|
shelfStatus: this.getFilterStream(getShelfStatusFilter, 'id', 'name'),
|
||||||
fileSize: this.getFilterStream((book: Book) => getFileSizeRangeFilters(book.fileSizeKb), 'id', 'name', 'sortIndex'),
|
fileSize: this.getFilterStream((book: Book) => getFileSizeRangeFilters(book.fileSizeKb), 'id', 'name', 'sortIndex'),
|
||||||
pageCount: this.getFilterStream((book: Book) => getPageCountRangeFilters(book.metadata?.pageCount!), '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!), '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!), '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!), 'id', 'name', 'sortIndex'),
|
hardcoverRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.hardcoverRating ?? undefined), 'id', 'name', 'sortIndex'),
|
||||||
};
|
};
|
||||||
|
|
||||||
this.filterTypes = Object.keys(this.filterStreams) as FilterType[];
|
this.filterTypes = Object.keys(this.filterStreams) as FilterType[];
|
||||||
@@ -469,18 +469,18 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
trackByFilter(_: number, filter: Filter<FilterValue>): unknown {
|
trackByFilter(_: number, filter: Filter<FilterValue>): unknown {
|
||||||
const value = filter.value as { id?: unknown } | 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<FilterValue>): unknown {
|
getFilterValueId(filter: Filter<FilterValue>): unknown {
|
||||||
const value = filter.value as { id?: unknown } | 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<FilterValue>): string {
|
getFilterValueDisplay(filter: Filter<FilterValue>): string {
|
||||||
const value = filter.value as { name?: string } | string | unknown;
|
const value = filter.value as { name?: string } | string | unknown;
|
||||||
if (typeof value === 'object' && value !== null && 'name' in value) {
|
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 ?? '');
|
return String(value ?? '');
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import {UrlHelperService} from '../../../../../shared/service/url-helper.service
|
|||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {BookService} from '../../../service/book.service';
|
import {BookService} from '../../../service/book.service';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {Router, RouterLink} from '@angular/router';
|
import {RouterLink} from '@angular/router';
|
||||||
import {filter, Subject} from 'rxjs';
|
import {filter, Subject} from 'rxjs';
|
||||||
import {UserService} from '../../../../settings/user-management/user.service';
|
import {UserService} from '../../../../settings/user-management/user.service';
|
||||||
import {take, takeUntil} from 'rxjs/operators';
|
import {take, takeUntil} from 'rxjs/operators';
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Component, inject, OnDestroy } from "@angular/core";
|
|
||||||
import { FormsModule } from "@angular/forms";
|
import { FormsModule } from "@angular/forms";
|
||||||
import { Button } from "primeng/button";
|
import { Button } from "primeng/button";
|
||||||
import { ActivatedRoute } from "@angular/router";
|
import { ActivatedRoute } from "@angular/router";
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@
|
|||||||
class="input-full"
|
class="input-full"
|
||||||
placeholder="e.g., Favorites, To Read, Currently Reading"
|
placeholder="e.g., Favorites, To Read, Currently Reading"
|
||||||
[class.filled]="shelfName.trim()"
|
[class.filled]="shelfName.trim()"
|
||||||
autofocus
|
|
||||||
/>
|
/>
|
||||||
@if (shelfName.trim()) {
|
@if (shelfName.trim()) {
|
||||||
<i class="pi pi-check-circle input-icon success"></i>
|
<i class="pi pi-check-circle input-icon success"></i>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export class LibraryShelfMenuService {
|
|||||||
label: 'Edit Library',
|
label: 'Edit Library',
|
||||||
icon: 'pi pi-pen-to-square',
|
icon: 'pi pi-pen-to-square',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.dialogLauncherService.openLibraryEditDialog(<number>entity?.id);
|
this.dialogLauncherService.openLibraryEditDialog((entity?.id as number));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -77,7 +77,7 @@ export class LibraryShelfMenuService {
|
|||||||
label: 'Custom Fetch Metadata',
|
label: 'Custom Fetch Metadata',
|
||||||
icon: 'pi pi-sync',
|
icon: 'pi pi-sync',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.dialogLauncherService.openLibraryMetadataFetchDialog(<number>entity?.id);
|
this.dialogLauncherService.openLibraryMetadataFetchDialog((entity?.id as number));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -144,7 +144,7 @@ export class LibraryShelfMenuService {
|
|||||||
label: 'Edit Shelf',
|
label: 'Edit Shelf',
|
||||||
icon: 'pi pi-pen-to-square',
|
icon: 'pi pi-pen-to-square',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.dialogLauncherService.openShelfEditDialog(<number>entity?.id);
|
this.dialogLauncherService.openShelfEditDialog((entity?.id as number));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -197,7 +197,7 @@ export class LibraryShelfMenuService {
|
|||||||
icon: 'pi pi-pen-to-square',
|
icon: 'pi pi-pen-to-square',
|
||||||
disabled: disableOptions,
|
disabled: disableOptions,
|
||||||
command: () => {
|
command: () => {
|
||||||
this.dialogLauncherService.openMagicShelfEditDialog(<number>entity?.id);
|
this.dialogLauncherService.openMagicShelfEditDialog((entity?.id as number));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -267,7 +267,7 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
|
|||||||
return preview.success ? 'pi-check-circle' : 'pi-times-circle';
|
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}));
|
return Object.entries(preview.preview).map(([key, value]) => ({key, value}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -137,7 +137,7 @@ export class MainDashboardComponent implements OnInit {
|
|||||||
|
|
||||||
return this.bookService.bookState$.pipe(
|
return this.bookService.bookState$.pipe(
|
||||||
map((state: BookState) => {
|
map((state: BookState) => {
|
||||||
let filteredBooks = (state.books || []).filter((book) =>
|
const filteredBooks = (state.books || []).filter((book) =>
|
||||||
this.ruleEvaluatorService.evaluateGroup(book, group)
|
this.ruleEvaluatorService.evaluateGroup(book, group)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -128,9 +128,9 @@ export class LibraryCreatorComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
validateLibraryNameAndProceed(activateCallback: Function): void {
|
validateLibraryNameAndProceed(activateCallback: Function): void {
|
||||||
let trimmedLibraryName = this.chosenLibraryName.trim();
|
const trimmedLibraryName = this.chosenLibraryName.trim();
|
||||||
if (trimmedLibraryName && trimmedLibraryName != this.editModeLibraryName) {
|
if (trimmedLibraryName && trimmedLibraryName != this.editModeLibraryName) {
|
||||||
let exists = this.libraryService.doesLibraryExistByName(trimmedLibraryName);
|
const exists = this.libraryService.doesLibraryExistByName(trimmedLibraryName);
|
||||||
if (exists) {
|
if (exists) {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ export class MagicShelfComponent implements OnInit {
|
|||||||
|
|
||||||
createGroup(): GroupFormGroup {
|
createGroup(): GroupFormGroup {
|
||||||
return new FormGroup({
|
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'),
|
join: new FormControl<'and' | 'or'>('and' as 'and' | 'or'),
|
||||||
rules: new FormArray([] as (GroupFormGroup | RuleFormGroup)[]),
|
rules: new FormArray([] as (GroupFormGroup | RuleFormGroup)[]),
|
||||||
}) as GroupFormGroup;
|
}) as GroupFormGroup;
|
||||||
|
|||||||
+10
-2
@@ -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 {CommonModule} from '@angular/common';
|
||||||
import {ReadingSessionApiService, ReadingSessionResponse} from '../../../../../shared/service/reading-session-api.service';
|
import {ReadingSessionApiService, ReadingSessionResponse} from '../../../../../shared/service/reading-session-api.service';
|
||||||
import {TableModule} from 'primeng/table';
|
import {TableModule} from 'primeng/table';
|
||||||
@@ -16,6 +16,7 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
|
|||||||
@Input() bookId!: number;
|
@Input() bookId!: number;
|
||||||
|
|
||||||
private readonly readingSessionService = inject(ReadingSessionApiService);
|
private readonly readingSessionService = inject(ReadingSessionApiService);
|
||||||
|
private readonly cdr = inject(ChangeDetectorRef);
|
||||||
|
|
||||||
sessions: ReadingSessionResponse[] = [];
|
sessions: ReadingSessionResponse[] = [];
|
||||||
totalRecords = 0;
|
totalRecords = 0;
|
||||||
@@ -24,7 +25,7 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
|
|||||||
loading = false;
|
loading = false;
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.loadSessions();
|
// Rely on p-table onLazyLoad to trigger the initial load
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
@@ -35,16 +36,23 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadSessions(page: number = 0) {
|
loadSessions(page: number = 0) {
|
||||||
|
// Prevent ExpressionChangedAfterItHasBeenCheckedError
|
||||||
|
setTimeout(() => {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
this.cdr.markForCheck();
|
||||||
|
});
|
||||||
|
|
||||||
this.readingSessionService.getSessionsByBookId(this.bookId, page, this.rows)
|
this.readingSessionService.getSessionsByBookId(this.bookId, page, this.rows)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
this.sessions = response.content;
|
this.sessions = response.content;
|
||||||
this.totalRecords = response.totalElements;
|
this.totalRecords = response.totalElements;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
this.cdr.markForCheck();
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
this.cdr.markForCheck();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -600,7 +600,7 @@ export class MetadataEditorComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateMetadata(shouldLockAllFields: boolean | undefined): void {
|
private updateMetadata(shouldLockAllFields: boolean | undefined): void {
|
||||||
let metadataUpdateWrapper = this.buildMetadataWrapper(shouldLockAllFields);
|
const metadataUpdateWrapper = this.buildMetadataWrapper(shouldLockAllFields);
|
||||||
this.bookService
|
this.bookService
|
||||||
.updateBookMetadata(this.currentBookId, metadataUpdateWrapper, false)
|
.updateBookMetadata(this.currentBookId, metadataUpdateWrapper, false)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
|
|||||||
+1
-1
@@ -677,7 +677,7 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
this.goBack.emit(true);
|
this.goBack.emit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
hoveredFields: { [key: string]: boolean } = {};
|
hoveredFields: Record<string, boolean> = {};
|
||||||
|
|
||||||
onMouseEnter(controlName: string): void {
|
onMouseEnter(controlName: string): void {
|
||||||
if (this.isValueCopied(controlName) && !this.isValueSaved(controlName)) {
|
if (this.isValueCopied(controlName) && !this.isValueSaved(controlName)) {
|
||||||
|
|||||||
+1
-1
@@ -439,7 +439,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assignShelf(bookId: number) {
|
assignShelf(bookId: number) {
|
||||||
this.bookDialogHelperService.openShelfAssignerDialog(<Book>this.bookService.getBookByIdFromState(bookId), null);
|
this.bookDialogHelperService.openShelfAssignerDialog((this.bookService.getBookByIdFromState(bookId) as Book), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateReadStatus(status: ReadStatus): void {
|
updateReadStatus(status: ReadStatus): void {
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ export class CoverSearchComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.bookId = this.dynamicDialogConfig.data.bookId;
|
this.bookId = this.dynamicDialogConfig.data.bookId;
|
||||||
let book = this.bookService.getBookByIdFromState(this.bookId);
|
const book = this.bookService.getBookByIdFromState(this.bookId);
|
||||||
|
|
||||||
if (book) {
|
if (book) {
|
||||||
this.searchForm.patchValue({
|
this.searchForm.patchValue({
|
||||||
|
|||||||
@@ -257,6 +257,11 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
|||||||
const cfi = this.rendition.currentLocation()?.start?.cfi;
|
const cfi = this.rendition.currentLocation()?.start?.cfi;
|
||||||
const locations = this.book.locations.save();
|
const locations = this.book.locations.save();
|
||||||
|
|
||||||
|
if (this.rendition) {
|
||||||
|
this.rendition.destroy();
|
||||||
|
this.rendition = null;
|
||||||
|
}
|
||||||
|
|
||||||
this.initBook(locations);
|
this.initBook(locations);
|
||||||
this.initRendition(cfi);
|
this.initRendition(cfi);
|
||||||
this.updateViewerSetting();
|
this.updateViewerSetting();
|
||||||
@@ -268,6 +273,11 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
|||||||
const cfi = this.rendition.currentLocation()?.start?.cfi;
|
const cfi = this.rendition.currentLocation()?.start?.cfi;
|
||||||
const locations = this.book.locations.save();
|
const locations = this.book.locations.save();
|
||||||
|
|
||||||
|
if (this.rendition) {
|
||||||
|
this.rendition.destroy();
|
||||||
|
this.rendition = null;
|
||||||
|
}
|
||||||
|
|
||||||
this.initBook(locations);
|
this.initBook(locations);
|
||||||
this.initRendition(cfi);
|
this.initRendition(cfi);
|
||||||
this.updateViewerSetting();
|
this.updateViewerSetting();
|
||||||
@@ -829,7 +839,23 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
if (this.rendition) {
|
if (this.rendition) {
|
||||||
this.rendition.off('keyup', this.keyListener);
|
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);
|
document.removeEventListener('keyup', this.keyListener);
|
||||||
|
|
||||||
if (this.hideControlsTimeout) {
|
if (this.hideControlsTimeout) {
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ export function getCfiFromHref(book: Book, href: string): string | null {
|
|||||||
const section = book.spine.get(href);
|
const section = book.spine.get(href);
|
||||||
|
|
||||||
if (!section || !section.document) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const el = id ? section.document.getElementById(id) : section.document.body;
|
const el = id ? section.document.getElementById(id) : section.document.body;
|
||||||
if (!el) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@
|
|||||||
class="input-full"
|
class="input-full"
|
||||||
placeholder="e.g., Gmail SMTP, SendGrid"
|
placeholder="e.g., Gmail SMTP, SendGrid"
|
||||||
[class.filled]="emailProviderForm.get('name')?.value"
|
[class.filled]="emailProviderForm.get('name')?.value"
|
||||||
autofocus
|
|
||||||
/>
|
/>
|
||||||
@if (emailProviderForm.get('name')?.value && emailProviderForm.get('name')?.valid) {
|
@if (emailProviderForm.get('name')?.value && emailProviderForm.get('name')?.valid) {
|
||||||
<i class="pi pi-check-circle input-icon success"></i>
|
<i class="pi pi-check-circle input-icon success"></i>
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@
|
|||||||
class="input-full"
|
class="input-full"
|
||||||
placeholder="Enter recipient name..."
|
placeholder="Enter recipient name..."
|
||||||
[class.filled]="emailRecipientForm.get('name')?.value"
|
[class.filled]="emailRecipientForm.get('name')?.value"
|
||||||
autofocus
|
|
||||||
/>
|
/>
|
||||||
@if (emailRecipientForm.get('name')?.value && emailRecipientForm.get('name')?.valid) {
|
@if (emailRecipientForm.get('name')?.value && emailRecipientForm.get('name')?.valid) {
|
||||||
<i class="pi pi-check-circle input-icon success"></i>
|
<i class="pi pi-check-circle input-icon success"></i>
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ export class LibraryMetadataSettingsComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
|
|
||||||
defaultMetadataOptions: MetadataRefreshOptions = this.getDefaultMetadataOptions();
|
defaultMetadataOptions: MetadataRefreshOptions = this.getDefaultMetadataOptions();
|
||||||
libraryMetadataOptions: { [libraryId: number]: MetadataRefreshOptions } = {};
|
libraryMetadataOptions: Record<number, MetadataRefreshOptions> = {};
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.appSettingsService.appSettings$.subscribe(appSettings => {
|
this.appSettingsService.appSettings$.subscribe(appSettings => {
|
||||||
|
|||||||
+2
-2
@@ -18,13 +18,13 @@ export class PdfReaderPreferencesComponent {
|
|||||||
|
|
||||||
@Input() userSettings!: UserSettings;
|
@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: 'Even', key: 'even', icon: 'pi pi-align-left'},
|
||||||
{name: 'Odd', key: 'odd', icon: 'pi pi-align-right'},
|
{name: 'Odd', key: 'odd', icon: 'pi pi-align-right'},
|
||||||
{name: 'None', key: 'off', icon: 'pi pi-minus'}
|
{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: 'Auto Zoom', key: 'auto', icon: 'pi pi-sparkles'},
|
||||||
{name: 'Page Fit', key: 'page-fit', icon: 'pi pi-window-maximize'},
|
{name: 'Page Fit', key: 'page-fit', icon: 'pi pi-window-maximize'},
|
||||||
{name: 'Page Width', key: 'page-width', icon: 'pi pi-arrows-h'},
|
{name: 'Page Width', key: 'page-width', icon: 'pi pi-arrows-h'},
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// State
|
// State
|
||||||
taskInfos: TaskInfo[] = [];
|
taskInfos: TaskInfo[] = [];
|
||||||
taskHistories: Map<string, TaskHistory> = new Map();
|
taskHistories = new Map<string, TaskHistory>();
|
||||||
loading = false;
|
loading = false;
|
||||||
executingTasks = new Set<string>();
|
executingTasks = new Set<string>();
|
||||||
private subscription?: Subscription;
|
private subscription?: Subscription;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export class UserManagementComponent implements OnInit, OnDestroy {
|
|||||||
currentUser: User | null = null;
|
currentUser: User | null = null;
|
||||||
editingLibraryIds: number[] = [];
|
editingLibraryIds: number[] = [];
|
||||||
allLibraries: Library[] = [];
|
allLibraries: Library[] = [];
|
||||||
expandedRows: { [key: string]: boolean } = {};
|
expandedRows: Record<string, boolean> = {};
|
||||||
|
|
||||||
isPasswordDialogVisible = false;
|
isPasswordDialogVisible = false;
|
||||||
selectedUser: User | null = null;
|
selectedUser: User | null = null;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export interface CompletionTimelineResponse {
|
|||||||
year: number;
|
year: number;
|
||||||
month: number;
|
month: number;
|
||||||
totalBooks: number;
|
totalBooks: number;
|
||||||
statusBreakdown: { [key: string]: number };
|
statusBreakdown: Record<string, number>;
|
||||||
finishedBooks: number;
|
finishedBooks: number;
|
||||||
completionRate: number;
|
completionRate: number;
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ export class UserStatsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFavoriteDays(year?: number, month?: number): Observable<FavoriteDaysResponse[]> {
|
getFavoriteDays(year?: number, month?: number): Observable<FavoriteDaysResponse[]> {
|
||||||
let params: Record<string, string> = {};
|
const params: Record<string, string> = {};
|
||||||
if (year !== undefined && year !== null) {
|
if (year !== undefined && year !== null) {
|
||||||
params['year'] = year.toString();
|
params['year'] = year.toString();
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ export class UserStatsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPeakHours(year?: number, month?: number): Observable<PeakHoursResponse[]> {
|
getPeakHours(year?: number, month?: number): Observable<PeakHoursResponse[]> {
|
||||||
let params: Record<string, string> = {};
|
const params: Record<string, string> = {};
|
||||||
if (year !== undefined && year !== null) {
|
if (year !== undefined && year !== null) {
|
||||||
params['year'] = year.toString();
|
params['year'] = year.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -174,7 +174,7 @@ export class ReadingSessionHeatmapComponent implements OnInit, OnDestroy {
|
|||||||
firstMonday.setDate(firstMonday.getDate() - daysToMonday);
|
firstMonday.setDate(firstMonday.getDate() - daysToMonday);
|
||||||
|
|
||||||
let weekIndex = 0;
|
let weekIndex = 0;
|
||||||
let currentDate = new Date(firstMonday);
|
const currentDate = new Date(firstMonday);
|
||||||
|
|
||||||
while (currentDate <= endDate || weekIndex === 0) {
|
while (currentDate <= endDate || weekIndex === 0) {
|
||||||
for (let dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) {
|
for (let dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) {
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ export class DirectoryPickerComponent implements OnInit {
|
|||||||
filteredPaths: string[] = [];
|
filteredPaths: string[] = [];
|
||||||
selectedProductName: string = '';
|
selectedProductName: string = '';
|
||||||
selectedFolders: string[] = [];
|
selectedFolders: string[] = [];
|
||||||
selectedFoldersMap: { [key: string]: boolean } = {};
|
selectedFoldersMap: Record<string, boolean> = {};
|
||||||
searchQuery: string = '';
|
searchQuery: string = '';
|
||||||
isLoading: boolean = false;
|
isLoading: boolean = false;
|
||||||
breadcrumbItems: MenuItem[] = [];
|
breadcrumbItems: MenuItem[] = [];
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export class FileMoverComponent implements OnDestroy {
|
|||||||
loading = false;
|
loading = false;
|
||||||
patternsCollapsed = true;
|
patternsCollapsed = true;
|
||||||
|
|
||||||
bookIds: Set<number> = new Set();
|
bookIds = new Set<number>();
|
||||||
books: Book[] = [];
|
books: Book[] = [];
|
||||||
availableLibraries: { id: number | null; name: string }[] = [];
|
availableLibraries: { id: number | null; name: string }[] = [];
|
||||||
filePreviews: FilePreview[] = [];
|
filePreviews: FilePreview[] = [];
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@ import {DialogLauncherService} from '../../services/dialog-launcher.service';
|
|||||||
imports: [KeyValuePipe, ProgressBarModule, ButtonModule, Divider, Tooltip, Tag]
|
imports: [KeyValuePipe, ProgressBarModule, ButtonModule, Divider, Tooltip, Tag]
|
||||||
})
|
})
|
||||||
export class MetadataProgressWidgetComponent implements OnInit, OnDestroy {
|
export class MetadataProgressWidgetComponent implements OnInit, OnDestroy {
|
||||||
activeTasks: { [taskId: string]: MetadataBatchProgressNotification } = {};
|
activeTasks: Record<string, MetadataBatchProgressNotification> = {};
|
||||||
|
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
private dialogLauncherService = inject(DialogLauncherService);
|
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<string, MetadataBatchProgressNotification>): void {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|
||||||
for (const taskId of this.timeoutHandles.keys()) {
|
for (const taskId of this.timeoutHandles.keys()) {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export class AppTopBarComponent implements OnDestroy {
|
|||||||
private eventTimer: number | undefined;
|
private eventTimer: number | undefined;
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
private latestTasks: { [taskId: string]: MetadataBatchProgressNotification } = {};
|
private latestTasks: Record<string, MetadataBatchProgressNotification> = {};
|
||||||
private latestHasPendingFiles = false;
|
private latestHasPendingFiles = false;
|
||||||
private latestNotificationSeverity?: Severity;
|
private latestNotificationSeverity?: Severity;
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ export class AppTopBarComponent implements OnDestroy {
|
|||||||
this.completedTaskCount = completedMetadataTasks + bookdropFileTaskCount;
|
this.completedTaskCount = completedMetadataTasks + bookdropFileTaskCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateTaskVisibility(tasks: { [taskId: string]: MetadataBatchProgressNotification }) {
|
private updateTaskVisibility(tasks: Record<string, MetadataBatchProgressNotification>) {
|
||||||
this.hasActiveOrCompletedTasks =
|
this.hasActiveOrCompletedTasks =
|
||||||
this.progressHighlight || this.completedTaskCount > 0 || Object.keys(tasks).length > 0;
|
this.progressHighlight || this.completedTaskCount > 0 || Object.keys(tasks).length > 0;
|
||||||
this.updateTaskVisibilityWithBookdrop();
|
this.updateTaskVisibilityWithBookdrop();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export class MetadataProgressService implements OnDestroy {
|
|||||||
private progressUpdatesSubject = new Subject<MetadataBatchProgressNotification>();
|
private progressUpdatesSubject = new Subject<MetadataBatchProgressNotification>();
|
||||||
progressUpdates$ = this.progressUpdatesSubject.asObservable();
|
progressUpdates$ = this.progressUpdatesSubject.asObservable();
|
||||||
|
|
||||||
private activeTasksSubject = new BehaviorSubject<{ [taskId: string]: MetadataBatchProgressNotification }>({});
|
private activeTasksSubject = new BehaviorSubject<Record<string, MetadataBatchProgressNotification>>({});
|
||||||
activeTasks$ = this.activeTasksSubject.asObservable();
|
activeTasks$ = this.activeTasksSubject.asObservable();
|
||||||
|
|
||||||
private metadataTaskService = inject(MetadataTaskService);
|
private metadataTaskService = inject(MetadataTaskService);
|
||||||
@@ -58,8 +58,8 @@ export class MetadataProgressService implements OnDestroy {
|
|||||||
this.activeTasksSubject.next(this.getActiveTasks());
|
this.activeTasksSubject.next(this.getActiveTasks());
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveTasks(): { [taskId: string]: MetadataBatchProgressNotification } {
|
getActiveTasks(): Record<string, MetadataBatchProgressNotification> {
|
||||||
const result: { [taskId: string]: MetadataBatchProgressNotification } = {};
|
const result: Record<string, MetadataBatchProgressNotification> = {};
|
||||||
this.progressMap.forEach((subject, taskId) => {
|
this.progressMap.forEach((subject, taskId) => {
|
||||||
result[taskId] = subject.getValue();
|
result[taskId] = subject.getValue();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,9 +24,7 @@ interface SvgIconBatchResponse {
|
|||||||
results: IconSaveResult[];
|
results: IconSaveResult[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IconContentMap {
|
type IconContentMap = Record<string, string>;
|
||||||
[iconName: string]: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
|||||||
Reference in New Issue
Block a user