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:
+1
-1
@@ -37,7 +37,7 @@ export class DirectoryPickerComponent implements OnInit {
|
||||
filteredPaths: string[] = [];
|
||||
selectedProductName: string = '';
|
||||
selectedFolders: string[] = [];
|
||||
selectedFoldersMap: { [key: string]: boolean } = {};
|
||||
selectedFoldersMap: Record<string, boolean> = {};
|
||||
searchQuery: string = '';
|
||||
isLoading: boolean = false;
|
||||
breadcrumbItems: MenuItem[] = [];
|
||||
|
||||
@@ -61,7 +61,7 @@ export class FileMoverComponent implements OnDestroy {
|
||||
loading = false;
|
||||
patternsCollapsed = true;
|
||||
|
||||
bookIds: Set<number> = new Set();
|
||||
bookIds = new Set<number>();
|
||||
books: Book[] = [];
|
||||
availableLibraries: { id: number | null; name: string }[] = [];
|
||||
filePreviews: FilePreview[] = [];
|
||||
|
||||
+2
-2
@@ -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<string, MetadataBatchProgressNotification> = {};
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
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();
|
||||
|
||||
for (const taskId of this.timeoutHandles.keys()) {
|
||||
|
||||
@@ -71,7 +71,7 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
private eventTimer: number | undefined;
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
private latestTasks: { [taskId: string]: MetadataBatchProgressNotification } = {};
|
||||
private latestTasks: Record<string, MetadataBatchProgressNotification> = {};
|
||||
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<string, MetadataBatchProgressNotification>) {
|
||||
this.hasActiveOrCompletedTasks =
|
||||
this.progressHighlight || this.completedTaskCount > 0 || Object.keys(tasks).length > 0;
|
||||
this.updateTaskVisibilityWithBookdrop();
|
||||
|
||||
@@ -12,7 +12,7 @@ export class MetadataProgressService implements OnDestroy {
|
||||
private progressUpdatesSubject = new Subject<MetadataBatchProgressNotification>();
|
||||
progressUpdates$ = this.progressUpdatesSubject.asObservable();
|
||||
|
||||
private activeTasksSubject = new BehaviorSubject<{ [taskId: string]: MetadataBatchProgressNotification }>({});
|
||||
private activeTasksSubject = new BehaviorSubject<Record<string, MetadataBatchProgressNotification>>({});
|
||||
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<string, MetadataBatchProgressNotification> {
|
||||
const result: Record<string, MetadataBatchProgressNotification> = {};
|
||||
this.progressMap.forEach((subject, taskId) => {
|
||||
result[taskId] = subject.getValue();
|
||||
});
|
||||
|
||||
@@ -24,9 +24,7 @@ interface SvgIconBatchResponse {
|
||||
results: IconSaveResult[];
|
||||
}
|
||||
|
||||
interface IconContentMap {
|
||||
[iconName: string]: string;
|
||||
}
|
||||
type IconContentMap = Record<string, string>;
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
||||
Reference in New Issue
Block a user