Skip to content

Commit

Permalink
revert lazy loading of child routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuzzy3 committed Feb 24, 2025
1 parent b8cea6a commit 9a25a4b
Showing 1 changed file with 7 additions and 27 deletions.
34 changes: 7 additions & 27 deletions libs/designsystem/modal/src/modal-navigation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,11 @@ export class ModalNavigationService {
let modalRoutes: string[] = [];
const moduleRootPaths = await this.getModuleRootPath(flattenedRoutes, moduleRootRoutePath);
if (moduleRootPaths) {
modalRoutes = await this.getModalRoutePaths(flattenedRoutes, moduleRootPaths);
modalRoutes = this.getModalRoutePaths(flattenedRoutes, moduleRootPaths);
}
return modalRoutes;
}

private async getLazyLoadedChildRoutes(route: Route): Promise<Routes> {
if (route?.loadChildren) {
const lazyLoadedChildren = await route.loadChildren();
if (Array.isArray(lazyLoadedChildren)) {
return lazyLoadedChildren;
}
}
return [];
}

private async getModuleRootPath(routes: Routes, moduleRootRoutePath?: string): Promise<string[]> {
if (moduleRootRoutePath) {
const trimmedPaths = moduleRootRoutePath
Expand Down Expand Up @@ -173,7 +163,7 @@ export class ModalNavigationService {
return routes.concat(this.getRoutePaths(route.children, currentPath));
}

private async getModalRoutePath(route: Route, parentPath: string[]): Promise<string[]> {
private getModalRoutePath(route: Route, parentPath: string[]): string[] {
const modalOutletName = 'modal';
if (!!route.path && route.outlet === modalOutletName) {
const modalOutletPath = `(${modalOutletName}:${route.path})`;
Expand All @@ -184,23 +174,13 @@ export class ModalNavigationService {
if (route.path) {
currentPath.push(route.path);
}
//If route has lazy loaded childen then get the paths for those children
if (route.loadChildren) {
return ([] as string[]).concat(
await this.getModalRoutePaths(await this.getLazyLoadedChildRoutes(route), currentPath)
);
}
return ([] as string[]).concat(await this.getModalRoutePaths(route.children, currentPath));
return ([] as string[]).concat(...this.getModalRoutePaths(route.children, currentPath));
}

private async getModalRoutePaths(routes: Routes, parentPath: string[]): Promise<string[]> {
if (!Array.isArray(routes)) {
return [];
}
const modalRoutePaths = await Promise.all(
routes.map((route) => this.getModalRoutePath(route, parentPath))
);
return ([] as string[]).concat(...modalRoutePaths);
private getModalRoutePaths(routes: Routes, parentPath: string[]): string[] {
return Array.isArray(routes)
? ([] as string[]).concat(...routes.map((route) => this.getModalRoutePath(route, parentPath)))
: [];
}

private isNewModalWindow(navigationEnd: NavigationEnd): boolean {
Expand Down

0 comments on commit 9a25a4b

Please sign in to comment.