Skip to content

Commit

Permalink
Fix the issue where the public dataset search result page displays pu…
Browse files Browse the repository at this point in the history
…blic 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)
  • Loading branch information
GspikeHalo authored Jan 27, 2025
1 parent 5e7568e commit d349903
Showing 1 changed file with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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";
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()
Expand All @@ -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;

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit d349903

Please sign in to comment.