fix(loading): update loading checks to use signal() for reactive state management (#727)

This commit is contained in:
brios
2026-04-22 17:27:43 -04:00
committed by Zach Yale
parent 7a88b12430
commit 284e7bec49
59 changed files with 577 additions and 345 deletions
@@ -61,7 +61,7 @@
type="submit"
[label]="t('searchBtn')"
icon="pi pi-search"
[loading]="loading"
[loading]="loading()"
[disabled]="searchForm.invalid">
</p-button>
<p-button
@@ -81,7 +81,7 @@
<!-- Results Area -->
<div class="results-section">
@if (!hasSearched) {
@if (!hasSearched()) {
<!-- Initial State -->
<div class="empty-state">
<div class="empty-state-icon">
@@ -90,7 +90,7 @@
<h3>{{ t('searchForCovers') }}</h3>
<p>{{ t('searchForCoversDescription') }}</p>
</div>
} @else if (loading) {
} @else if (loading()) {
<!-- Loading State -->
<div class="loading-state">
<p-progressSpinner strokeWidth="3" animationDuration="1s"></p-progressSpinner>
@@ -1,4 +1,4 @@
import {Component, inject, Input, OnInit} from '@angular/core';
import {Component, inject, Input, OnInit, signal} from '@angular/core';
import {MessageService} from 'primeng/api';
import {FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms';
import {BookCoverService, CoverFetchRequest, CoverImage} from '../../../../shared/services/book-cover.service';
@@ -32,8 +32,8 @@ export class CoverSearchComponent implements OnInit {
@Input() bookId!: number;
searchForm: FormGroup;
coverImages: CoverImage[] = [];
loading = false;
hasSearched = false;
loading = signal(false);
hasSearched = signal(false);
coverType: 'ebook' | 'audiobook' = 'ebook';
private fb = inject(FormBuilder);
@@ -79,7 +79,7 @@ export class CoverSearchComponent implements OnInit {
onSearch() {
if (this.searchForm.valid) {
this.loading = true;
this.loading.set(true);
this.coverImages = [];
const request: CoverFetchRequest = {
bookId: this.bookId,
@@ -90,8 +90,8 @@ export class CoverSearchComponent implements OnInit {
this.bookCoverService.fetchBookCovers(request)
.pipe(finalize(() => {
this.loading = false;
this.hasSearched = true;
this.loading.set(false);
this.hasSearched.set(true);
}))
.subscribe({
next: (image) => {
@@ -139,6 +139,6 @@ export class CoverSearchComponent implements OnInit {
onClear() {
this.searchForm.reset();
this.coverImages = [];
this.hasSearched = false;
this.hasSearched.set(false);
}
}