diff --git a/core/gui/src/app/hub/component/hub-search-result/hub-search-result.component.ts b/core/gui/src/app/hub/component/hub-search-result/hub-search-result.component.ts index 34c7943e5a..5f6c144989 100644 --- a/core/gui/src/app/hub/component/hub-search-result/hub-search-result.component.ts +++ b/core/gui/src/app/hub/component/hub-search-result/hub-search-result.component.ts @@ -1,5 +1,5 @@ -import { AfterViewInit, Component, Input, ViewChild } from "@angular/core"; -import { Router, NavigationEnd } from "@angular/router"; +import { AfterViewInit, Component, Input, OnInit, ViewChild } from "@angular/core"; +import { Router } from "@angular/router"; import { SearchResultsComponent } from "../../../dashboard/component/user/search-results/search-results.component"; import { FiltersComponent } from "../../../dashboard/component/user/filters/filters.component"; import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; @@ -7,7 +7,7 @@ import { SortMethod } from "../../../dashboard/type/sort-method"; import { UserService } from "../../../common/service/user/user.service"; import { SearchService } from "../../../dashboard/service/user/search.service"; import { isDefined } from "../../../common/util/predicate"; -import { firstValueFrom, filter } from "rxjs"; +import { firstValueFrom } from "rxjs"; import { DashboardEntry, UserInfo } from "../../../dashboard/type/dashboard-entry"; @UntilDestroy() @@ -16,7 +16,7 @@ import { DashboardEntry, UserInfo } from "../../../dashboard/type/dashboard-entr templateUrl: "./hub-search-result.component.html", styleUrls: ["./hub-search-result.component.scss"], }) -export class HubSearchResultComponent implements AfterViewInit { +export class HubSearchResultComponent implements OnInit, AfterViewInit { public searchType: "dataset" | "workflow" = "workflow"; currentUid = this.userService.getCurrentUser()?.uid; @@ -61,20 +61,15 @@ export class HubSearchResultComponent implements AfterViewInit { .subscribe(() => { this.currentUid = this.userService.getCurrentUser()?.uid; }); + } - this.router.events - .pipe( - filter(event => event instanceof NavigationEnd), - untilDestroyed(this) - ) - .subscribe((event: any) => { - const url = event.urlAfterRedirects.toLowerCase(); - if (url.includes("dataset")) { - this.searchType = "dataset"; - } else if (url.includes("workflow")) { - this.searchType = "workflow"; - } - }); + ngOnInit() { + const url = this.router.url; + if (url.includes("dataset")) { + this.searchType = "dataset"; + } else if (url.includes("workflow")) { + this.searchType = "workflow"; + } } ngAfterViewInit() {