refactor(ebook-reader): optimize destruction handling and improve reactive subscriptions (#478)

This commit is contained in:
brios
2026-04-22 17:27:38 -04:00
committed by Zach Yale
parent e26df36a33
commit 1f5f99d958
26 changed files with 1112 additions and 1068 deletions
@@ -1,5 +1,5 @@
<ng-container *transloco="let t; prefix: 'authorBrowser.detail'">
@if (loading) {
@if (loading()) {
<div class="loading-state">
<p-progressSpinner strokeWidth="4" fill="transparent" animationDuration=".8s">
</p-progressSpinner>
@@ -7,7 +7,7 @@
</div>
}
@if (!loading && author(); as author) {
@if (!loading() && author(); as author) {
<div class="author-wrapper">
<p-tabs [value]="tab" lazy="true" scrollable>
<p-tablist>
@@ -144,7 +144,7 @@ describe('AuthorDetailComponent', () => {
expect(getAuthorDetails).toHaveBeenCalledWith(42);
expect(component.tab).toBe('series');
expect(component.loading).toBe(false);
expect(component.loading()).toBe(false);
expect(component.author()).toEqual({...baseAuthor, id: 42, name: 'Grace Hopper'});
expect(setPageTitle).toHaveBeenCalledWith('Grace Hopper');
});
@@ -158,7 +158,7 @@ describe('AuthorDetailComponent', () => {
component.ngOnInit();
expect(component.tab).toBe('books');
expect(component.loading).toBe(false);
expect(component.loading()).toBe(false);
expect(component.author()).toBeNull();
expect(setPageTitle).not.toHaveBeenCalled();
});
@@ -85,7 +85,7 @@ export class AuthorDetailComponent implements OnInit, AfterViewChecked {
private readonly viewportWidth = signal(0);
private viewportResizeObserver: ResizeObserver | undefined;
loading = true;
loading = signal(true);
tab = 'books';
isExpanded = false;
isOverflowing = false;
@@ -199,11 +199,11 @@ export class AuthorDetailComponent implements OnInit, AfterViewChecked {
this.authorService.getAuthorDetails(authorId).subscribe({
next: (author) => {
this.authorState.set(author);
this.loading = false;
this.loading.set(false);
this.pageTitle.setPageTitle(author.name);
},
error: () => {
this.loading = false;
this.loading.set(false);
}
});
}