From fce93a3ad51b3bba2f873a346efbd184bcca1987 Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Thu, 14 Jul 2022 14:23:51 +0200 Subject: [PATCH] MOBILE-4081 courses: Load 'my.module' from service --- src/core/features/courses/courses-lazy.module.ts | 3 ++- src/core/features/courses/services/courses-helper.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/features/courses/courses-lazy.module.ts b/src/core/features/courses/courses-lazy.module.ts index 595dbc641..38e98e5fc 100644 --- a/src/core/features/courses/courses-lazy.module.ts +++ b/src/core/features/courses/courses-lazy.module.ts @@ -15,6 +15,7 @@ import { Injector, NgModule } from '@angular/core'; import { RouterModule, ROUTES, Routes } from '@angular/router'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; +import { CoreCoursesHelper } from './services/courses-helper'; import { CoreCoursesMyCoursesMainMenuHandlerService } from './services/handlers/my-courses-mainmenu'; function buildRoutes(injector: Injector): Routes { @@ -24,7 +25,7 @@ function buildRoutes(injector: Injector): Routes { data: { mainMenuTabRoot: CoreCoursesMyCoursesMainMenuHandlerService.PAGE_NAME, }, - loadChildren: () => import('./pages/my/my.module').then(m => m.CoreCoursesMyCoursesPageModule), + loadChildren: () => CoreCoursesHelper.getMyRouteModule(), }, { path: 'categories', diff --git a/src/core/features/courses/services/courses-helper.ts b/src/core/features/courses/services/courses-helper.ts index 688db4f43..45c818d89 100644 --- a/src/core/features/courses/services/courses-helper.ts +++ b/src/core/features/courses/services/courses-helper.ts @@ -339,6 +339,15 @@ export class CoreCoursesHelperProvider { return startDate > Date.now(); } + /** + * Retrieves my courses page module. + * + * @returns My courses page module. + */ + async getMyRouteModule(): Promise { + return import('../pages/my/my.module').then(m => m.CoreCoursesMyCoursesPageModule); + } + } export const CoreCoursesHelper = makeSingleton(CoreCoursesHelperProvider);