Skip to content

Commit 7f6650a

Browse files
GspikeHaloMA77HEW820
authored andcommitted
Fix the issue where the public dataset search result page displays public workflows after refreshing (#3230)
### Purpose: Currently, after refreshing the public dataset search result page, public workflow search results appear. The issue occurs because the URL check and type update are only triggered when the `NavigationEnd` event is detected. However, when the page is refreshed, it retains the default type, which is the workflow search results. ### Changes: Directly check the URL and update the type in OnInit. ### Demos: Before: before refreshing: ![image](https://github.com/user-attachments/assets/d604b1e3-06b0-4324-bc57-c16cc05bfa99) after refreshing: ![image](https://github.com/user-attachments/assets/e9450fa5-71a5-4ac6-9fed-ab7abf4b1516) After: before refreshing: ![image](https://github.com/user-attachments/assets/d604b1e3-06b0-4324-bc57-c16cc05bfa99) after refreshing: ![image](https://github.com/user-attachments/assets/f6010494-f960-41dd-b553-08a64c9e2594)
1 parent 29503ea commit 7f6650a

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

core/gui/src/app/hub/component/hub-search-result/hub-search-result.component.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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";
33
import { SearchResultsComponent } from "../../../dashboard/component/user/search-results/search-results.component";
44
import { FiltersComponent } from "../../../dashboard/component/user/filters/filters.component";
55
import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy";
66
import { SortMethod } from "../../../dashboard/type/sort-method";
77
import { UserService } from "../../../common/service/user/user.service";
88
import { SearchService } from "../../../dashboard/service/user/search.service";
99
import { isDefined } from "../../../common/util/predicate";
10-
import { firstValueFrom, filter } from "rxjs";
10+
import { firstValueFrom } from "rxjs";
1111
import { DashboardEntry, UserInfo } from "../../../dashboard/type/dashboard-entry";
1212

1313
@UntilDestroy()
@@ -16,7 +16,7 @@ import { DashboardEntry, UserInfo } from "../../../dashboard/type/dashboard-entr
1616
templateUrl: "./hub-search-result.component.html",
1717
styleUrls: ["./hub-search-result.component.scss"],
1818
})
19-
export class HubSearchResultComponent implements AfterViewInit {
19+
export class HubSearchResultComponent implements OnInit, AfterViewInit {
2020
public searchType: "dataset" | "workflow" = "workflow";
2121
currentUid = this.userService.getCurrentUser()?.uid;
2222

@@ -61,20 +61,15 @@ export class HubSearchResultComponent implements AfterViewInit {
6161
.subscribe(() => {
6262
this.currentUid = this.userService.getCurrentUser()?.uid;
6363
});
64+
}
6465

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+
}
7873
}
7974

8075
ngAfterViewInit() {

0 commit comments

Comments
 (0)