chore(ui): clear final prefer-inject bucket
Convert the remaining feature and core constructors flagged by prefer-inject to field injection so the last Angular inject() violations are removed across upload dialogs, core services, and bookdrop flows. Validation: just ui lint
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import {inject, Pipe, PipeTransform} from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -9,7 +9,8 @@ import { map } from 'rxjs/operators';
|
||||
pure: true
|
||||
})
|
||||
export class SecurePipe implements PipeTransform {
|
||||
constructor(private http: HttpClient, private sanitizer: DomSanitizer) {}
|
||||
private http = inject(HttpClient);
|
||||
private sanitizer = inject(DomSanitizer);
|
||||
|
||||
transform(url: string): Observable<SafeUrl> {
|
||||
return this.http.get(url, { responseType: 'blob' }).pipe(
|
||||
|
||||
+6
-9
@@ -42,6 +42,12 @@ interface UploadingFile {
|
||||
})
|
||||
export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
private readonly t = inject(TranslocoService);
|
||||
private dialogRef = inject(DynamicDialogRef);
|
||||
private config = inject(DynamicDialogConfig);
|
||||
private bookFileService = inject(BookFileService);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private messageService = inject(MessageService);
|
||||
private cdr = inject(ChangeDetectorRef);
|
||||
|
||||
book!: Book;
|
||||
files: UploadingFile[] = [];
|
||||
@@ -57,15 +63,6 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(FileUpload) private fileUpload!: FileUpload;
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
private dialogRef: DynamicDialogRef,
|
||||
private config: DynamicDialogConfig,
|
||||
private bookFileService: BookFileService,
|
||||
private appSettingsService: AppSettingsService,
|
||||
private messageService: MessageService,
|
||||
private cdr: ChangeDetectorRef
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.book = this.config.data.book;
|
||||
this.fileTypeOptions = [
|
||||
|
||||
+5
-8
@@ -40,14 +40,11 @@ export class BookFileAttacherComponent implements OnInit, OnDestroy {
|
||||
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
|
||||
constructor(
|
||||
private dialogRef: DynamicDialogRef,
|
||||
private config: DynamicDialogConfig,
|
||||
private bookService: BookService,
|
||||
private bookFileService: BookFileService,
|
||||
private messageService: MessageService
|
||||
) {}
|
||||
private dialogRef = inject(DynamicDialogRef);
|
||||
private config = inject(DynamicDialogConfig);
|
||||
private bookService = inject(BookService);
|
||||
private bookFileService = inject(BookFileService);
|
||||
private messageService = inject(MessageService);
|
||||
|
||||
ngOnInit(): void {
|
||||
// Support both single book and multiple books
|
||||
|
||||
+4
-6
@@ -1,4 +1,4 @@
|
||||
import {Component, OnDestroy} from '@angular/core';
|
||||
import {Component, inject, OnDestroy} from '@angular/core';
|
||||
import {DatePipe, NgClass} from '@angular/common';
|
||||
import {BookdropFinalizeResult} from '../../service/bookdrop.service';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from "primeng/dynamicdialog";
|
||||
@@ -17,12 +17,10 @@ import {TranslocoDirective} from '@jsverse/transloco';
|
||||
styleUrl: './bookdrop-finalize-result-dialog.component.scss'
|
||||
})
|
||||
export class BookdropFinalizeResultDialogComponent implements OnDestroy {
|
||||
public ref = inject(DynamicDialogRef);
|
||||
public config = inject(DynamicDialogConfig);
|
||||
|
||||
result: BookdropFinalizeResult;
|
||||
|
||||
constructor(public ref: DynamicDialogRef, public config: DynamicDialogConfig) {
|
||||
this.result = config.data.result;
|
||||
}
|
||||
result: BookdropFinalizeResult = this.config.data.result;
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.ref?.close();
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import { Injectable, ComponentRef, ApplicationRef, createComponent, EnvironmentInjector } from '@angular/core';
|
||||
import {Injectable, ComponentRef, ApplicationRef, createComponent, EnvironmentInjector, inject} from '@angular/core';
|
||||
import { LibraryLoadingComponent } from './library-loading/library-loading.component';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LibraryLoadingService {
|
||||
private appRef = inject(ApplicationRef);
|
||||
private injector = inject(EnvironmentInjector);
|
||||
private componentRef: ComponentRef<LibraryLoadingComponent> | null = null;
|
||||
|
||||
constructor(
|
||||
private appRef: ApplicationRef,
|
||||
private injector: EnvironmentInjector
|
||||
) {}
|
||||
|
||||
showBookLoadingProgress(bookTitle: string, current: number, total: number): void {
|
||||
if (this.componentRef) {
|
||||
this.updateProgress(bookTitle, current, total);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
import {API_CONFIG} from '../../../core/config/api-config';
|
||||
@@ -76,10 +76,9 @@ export type SidecarSyncStatus = 'IN_SYNC' | 'OUTDATED' | 'MISSING' | 'CONFLICT'
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SidecarService {
|
||||
private http = inject(HttpClient);
|
||||
private readonly apiUrl = `${API_CONFIG.BASE_URL}/api/v1`;
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getSidecarContent(bookId: number): Observable<SidecarMetadata> {
|
||||
return this.http.get<SidecarMetadata>(`${this.apiUrl}/books/${bookId}/sidecar`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user