1
- import { AfterViewInit , Component , Input , ViewChild } from "@angular/core" ;
2
- import { Router , NavigationEnd } from "@angular/router" ;
1
+ import { AfterViewInit , Component , Input , OnInit , ViewChild } from "@angular/core" ;
2
+ import { Router } from "@angular/router" ;
3
3
import { SearchResultsComponent } from "../../../dashboard/component/user/search-results/search-results.component" ;
4
4
import { FiltersComponent } from "../../../dashboard/component/user/filters/filters.component" ;
5
5
import { UntilDestroy , untilDestroyed } from "@ngneat/until-destroy" ;
6
6
import { SortMethod } from "../../../dashboard/type/sort-method" ;
7
7
import { UserService } from "../../../common/service/user/user.service" ;
8
8
import { SearchService } from "../../../dashboard/service/user/search.service" ;
9
9
import { isDefined } from "../../../common/util/predicate" ;
10
- import { firstValueFrom , filter } from "rxjs" ;
10
+ import { firstValueFrom } from "rxjs" ;
11
11
import { DashboardEntry , UserInfo } from "../../../dashboard/type/dashboard-entry" ;
12
12
13
13
@UntilDestroy ( )
@@ -16,7 +16,7 @@ import { DashboardEntry, UserInfo } from "../../../dashboard/type/dashboard-entr
16
16
templateUrl : "./hub-search-result.component.html" ,
17
17
styleUrls : [ "./hub-search-result.component.scss" ] ,
18
18
} )
19
- export class HubSearchResultComponent implements AfterViewInit {
19
+ export class HubSearchResultComponent implements OnInit , AfterViewInit {
20
20
public searchType : "dataset" | "workflow" = "workflow" ;
21
21
currentUid = this . userService . getCurrentUser ( ) ?. uid ;
22
22
@@ -61,20 +61,15 @@ export class HubSearchResultComponent implements AfterViewInit {
61
61
. subscribe ( ( ) => {
62
62
this . currentUid = this . userService . getCurrentUser ( ) ?. uid ;
63
63
} ) ;
64
+ }
64
65
65
- this . router . events
66
- . pipe (
67
- filter ( event => event instanceof NavigationEnd ) ,
68
- untilDestroyed ( this )
69
- )
70
- . subscribe ( ( event : any ) => {
71
- const url = event . urlAfterRedirects . toLowerCase ( ) ;
72
- if ( url . includes ( "dataset" ) ) {
73
- this . searchType = "dataset" ;
74
- } else if ( url . includes ( "workflow" ) ) {
75
- this . searchType = "workflow" ;
76
- }
77
- } ) ;
66
+ ngOnInit ( ) {
67
+ const url = this . router . url ;
68
+ if ( url . includes ( "dataset" ) ) {
69
+ this . searchType = "dataset" ;
70
+ } else if ( url . includes ( "workflow" ) ) {
71
+ this . searchType = "workflow" ;
72
+ }
78
73
}
79
74
80
75
ngAfterViewInit ( ) {
0 commit comments