fix: clear search on going to main page

This commit is contained in:
2024-07-20 23:01:22 +03:00
parent 8c9efd4371
commit a81c7535c5
3 changed files with 14 additions and 7 deletions

View File

@@ -19,12 +19,18 @@ export class HeaderComponent implements AfterViewInit, OnDestroy {
private route: ActivatedRoute, private route: ActivatedRoute,
) { ) {
this.router.events this.router.events
.pipe(filter((event) => event instanceof NavigationEnd)) .pipe(
.pipe(takeUntil(this.destroy$)) filter((event) => event instanceof NavigationEnd),
takeUntil(this.destroy$),
)
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
.subscribe((val: any) => { .subscribe((val: any) => {
if (val.url.startsWith("/detail") || val.url.startsWith("/reader")) { if (val.url.startsWith("/detail") || val.url.startsWith("/reader")) {
this.menuOpened = false; this.menuOpened = false;
} else if (val.url === "/") {
if (this.searchInput) {
this.searchInput.nativeElement.value = "";
}
} }
}); });
} }

View File

@@ -42,12 +42,14 @@
title="{{ item.name }}" title="{{ item.name }}"
class="mb-6 max-w-[700px] w-full" class="mb-6 max-w-[700px] w-full"
> >
<div class="card flex flex-col items-center border-black border-2 rounded-md p-4 w-full"> <div
class="card flex flex-col items-center border-black border-2 rounded-md p-4 w-full h-[350px]"
>
<h1>{{ item.rus_name }}</h1> <h1>{{ item.rus_name }}</h1>
<img <img
[src]="item.cover.thumbnail" [src]="item.cover.thumbnail"
[alt]="item.slug" [alt]="item.slug"
class="w-[200px] h-auto aspect-auto" class="w-[200px] h-auto max-h-[300px] aspect-auto"
/> />
</div> </div>
</a> </a>

View File

@@ -9,7 +9,6 @@ import { IRulibDetailResult } from "./rulib.detail.dto";
import { IRuLIBPopular } from "./rulib.popular.dto"; import { IRuLIBPopular } from "./rulib.popular.dto";
import { IRulibSearchResult } from "./rulib.search.dto"; import { IRulibSearchResult } from "./rulib.search.dto";
//TODO: Make abstract classes
@Injectable({ @Injectable({
providedIn: "root", providedIn: "root",
}) })
@@ -102,7 +101,7 @@ export class LibSocialParserService extends Parser {
getPopular(): Observable<IRuLIBPopular[]> { getPopular(): Observable<IRuLIBPopular[]> {
return this.http return this.http
.get<{ data: { popular: [] } }>(`${this.url}/api/`, { .get<{ data: { popular: IRuLIBPopular[] } }>(`${this.url}/api/`, {
headers: { headers: {
Authorization: "Bearer " + this.rulibAuthService.getToken(), Authorization: "Bearer " + this.rulibAuthService.getToken(),
"Site-Id": this.site_id, "Site-Id": this.site_id,
@@ -110,7 +109,7 @@ export class LibSocialParserService extends Parser {
}) })
.pipe( .pipe(
map((data) => { map((data) => {
const res = data.data.popular as IRuLIBPopular[]; const res = data.data.popular;
return res; return res;
}), }),
catchError((error) => throwError(() => `Now found ${error}`)), catchError((error) => throwError(() => `Now found ${error}`)),