Simplify page redirection when the default route is used

This commit is contained in:
Abel Gómez
2025-03-13 22:44:32 +01:00
parent c212b3dccd
commit 262f758699

View File

@@ -121,6 +121,8 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
routerLink: `${comColRoute}/browse/${config.id}`,
})));
// When the default tab is not the "search" tab, the "search" tab is moved
// at the end of the tabs ribbon for aesthetics purposes.
if (this.appConfig[this.contentType].defaultBrowseTab !== 'search') {
allOptions.push(allOptions.shift());
}
@@ -138,17 +140,16 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
distinctUntilChanged(),
),
]).subscribe(([navOptions, url]: [ComColPageNavOption[], string]) => {
if (url?.split('?')[0].endsWith(`/${this.id}`)) {
const option = navOptions.find(o => o.id === this.appConfig[this.contentType].defaultBrowseTab);
void this.router.navigate([option.routerLink], { queryParams: option.params });
} else {
for (const option of navOptions) {
if (option.routerLink === url?.split('?')[0]) {
this.currentOption$.next(option);
}
}
}
}));
if (this.router.url?.split('?')[0].endsWith(`/${this.id}`)) {
void this.router.navigate([this.router.url, this.appConfig[this.contentType].defaultBrowseTab]);
}
}
ngOnDestroy(): void {