chore(ui): clear reader settings prefer-inject bucket

Convert reader settings and shared setup/custom-font components to field injection so these UI surfaces follow the project inject() convention without changing behavior.

Validation: just ui lint
This commit is contained in:
James Cox
2026-04-22 17:26:49 -04:00
committed by Zach Yale
parent b3fe4fd598
commit 4f7d38a306
6 changed files with 21 additions and 29 deletions
@@ -1,4 +1,4 @@
import {Component, EventEmitter, Inject, Input, OnInit, Output, Renderer2} from '@angular/core'; import {Component, EventEmitter, inject, Input, OnInit, Output, Renderer2} from '@angular/core';
import {DecimalPipe, DOCUMENT} from '@angular/common'; import {DecimalPipe, DOCUMENT} from '@angular/common';
import {TranslocoDirective} from '@jsverse/transloco'; import {TranslocoDirective} from '@jsverse/transloco';
import {ReaderStateService} from '../state/reader-state.service'; import {ReaderStateService} from '../state/reader-state.service';
@@ -39,13 +39,10 @@ export class ReaderSettingsDialogComponent implements OnInit {
{name: 'orange', value: '#FFD580', label: 'Orange'} {name: 'orange', value: '#FFD580', label: 'Orange'}
]; ];
constructor( private bookService = inject(BookService);
private bookService: BookService, private customFontService = inject(EpubCustomFontService);
private customFontService: EpubCustomFontService, private renderer = inject(Renderer2);
private renderer: Renderer2, private document = inject(DOCUMENT);
@Inject(DOCUMENT) private document: Document
) {
}
ngOnInit() { ngOnInit() {
this.customFontService.injectCustomFontsStylesheet(this.renderer, this.document); this.customFontService.injectCustomFontsStylesheet(this.renderer, this.document);
@@ -1,4 +1,4 @@
import {Component, EventEmitter, Input, Output} from '@angular/core'; import {Component, EventEmitter, inject, Input, Output} from '@angular/core';
import {DecimalPipe} from '@angular/common'; import {DecimalPipe} from '@angular/common';
import {TranslocoDirective} from '@jsverse/transloco'; import {TranslocoDirective} from '@jsverse/transloco';
import {ReaderStateService} from '../../state/reader-state.service'; import {ReaderStateService} from '../../state/reader-state.service';
@@ -19,7 +19,7 @@ export class ReaderQuickSettingsComponent {
@Output() closed = new EventEmitter<void>(); @Output() closed = new EventEmitter<void>();
@Output() openFullSettings = new EventEmitter<void>(); @Output() openFullSettings = new EventEmitter<void>();
constructor(private bookService: BookService) {} private bookService = inject(BookService);
get state() { get state() {
return this.stateService.state(); return this.stateService.state();
@@ -25,6 +25,8 @@ export interface ReaderState {
providedIn: 'root' providedIn: 'root'
}) })
export class ReaderStateService { export class ReaderStateService {
private bookService = inject(BookService);
private userService = inject(UserService);
private epubCustomFontService = inject(EpubCustomFontService); private epubCustomFontService = inject(EpubCustomFontService);
private readonly BASE_FONTS = [ private readonly BASE_FONTS = [
@@ -62,7 +64,7 @@ export class ReaderStateService {
private readonly _fonts = signal<{ name: string; value: string | null }[]>(this.BASE_FONTS); private readonly _fonts = signal<{ name: string; value: string | null }[]>(this.BASE_FONTS);
readonly fonts = this._fonts.asReadonly(); readonly fonts = this._fonts.asReadonly();
constructor(private bookService: BookService, private userService: UserService) { constructor() {
this.loadCustomFontsIntoList(); this.loadCustomFontsIntoList();
} }
@@ -29,15 +29,12 @@ export class CustomFontsComponent implements OnInit {
readonly maxFonts = 10; readonly maxFonts = 10;
private customFontService = inject(CustomFontService);
private messageService = inject(MessageService);
private confirmationService = inject(ConfirmationService);
private dialogService = inject(DialogService);
private t = inject(TranslocoService); private t = inject(TranslocoService);
constructor(
private customFontService: CustomFontService,
private messageService: MessageService,
private confirmationService: ConfirmationService,
private dialogService: DialogService
) {}
ngOnInit(): void { ngOnInit(): void {
this.loadFonts(); this.loadFonts();
} }
@@ -18,6 +18,9 @@ import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/tran
}) })
export class FontUploadDialogComponent implements OnDestroy { export class FontUploadDialogComponent implements OnDestroy {
@ViewChild('fileInput') fileInput!: ElementRef<HTMLInputElement>; @ViewChild('fileInput') fileInput!: ElementRef<HTMLInputElement>;
private customFontService = inject(CustomFontService);
private messageService = inject(MessageService);
private dialogRef = inject(DynamicDialogRef);
private readonly t = inject(TranslocoService); private readonly t = inject(TranslocoService);
isUploading = false; isUploading = false;
@@ -32,12 +35,6 @@ export class FontUploadDialogComponent implements OnDestroy {
readonly maxFonts = 10; readonly maxFonts = 10;
readonly acceptedFormats = ['.ttf', '.otf', '.woff', '.woff2']; readonly acceptedFormats = ['.ttf', '.otf', '.woff', '.woff2'];
constructor(
private customFontService: CustomFontService,
private messageService: MessageService,
private dialogRef: DynamicDialogRef
) {}
onUploadZoneClick(): void { onUploadZoneClick(): void {
if (this.isUploading) { if (this.isUploading) {
return; return;
@@ -22,17 +22,16 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
] ]
}) })
export class SetupComponent { export class SetupComponent {
private fb = inject(FormBuilder);
private setupService = inject(SetupService);
private router = inject(Router);
setupForm: FormGroup; setupForm: FormGroup;
loading = false; loading = false;
error: string | null = null; error: string | null = null;
success = false; success = false;
private readonly t = inject(TranslocoService); private readonly t = inject(TranslocoService);
constructor( constructor() {
private fb: FormBuilder,
private setupService: SetupService,
private router: Router
) {
this.setupForm = this.fb.group({ this.setupForm = this.fb.group({
name: ['', [Validators.required]], name: ['', [Validators.required]],
username: ['', [Validators.required]], username: ['', [Validators.required]],