refactor(ebook-reader): optimize destruction handling and improve reactive subscriptions (#478)
This commit is contained in:
+2
-2
@@ -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>
|
||||
|
||||
+2
-2
@@ -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();
|
||||
});
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user