From 5465d1635c4a0f5e4ac39ce36fc497cbf76d9101 Mon Sep 17 00:00:00 2001 From: Sergey Elpashev Date: Thu, 18 Jul 2024 16:50:48 +0300 Subject: [PATCH] feat: loading indication --- .../src/app/components/home/home.component.html | 6 ++++++ .../src/app/components/home/home.component.ts | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/NwaifuAnime/src/app/components/home/home.component.html b/apps/NwaifuAnime/src/app/components/home/home.component.html index 4485005..fe14cb8 100644 --- a/apps/NwaifuAnime/src/app/components/home/home.component.html +++ b/apps/NwaifuAnime/src/app/components/home/home.component.html @@ -1,5 +1,11 @@

It's home component

+ @if (loading) { +

Loading...

+ } + @if (notFound && !loading) { +

Not found

+ } @for (item of items; track $index) { (); @@ -27,15 +29,18 @@ export class HomeComponent implements OnDestroy, AfterViewInit { this.destroy$.complete(); } - ngAfterViewInit(): void { + ngOnInit(): void { this.route.queryParams.subscribe((params) => { const search = params["search"]; if (search) { + this.loading = true; this.searchService .search(search) .pipe(takeUntil(this.destroy$)) .subscribe((data) => { + this.loading = false; this.items = data.data; + this.notFound = this.items.length === 0; }); } });