Skip to content

Commit

Permalink
Merge pull request #4112 from crazyserver/MOBILE-4620
Browse files Browse the repository at this point in the history
MOBILE-4620 course: Async import main component to avoid crashes
  • Loading branch information
dpalou authored Jul 5, 2024
2 parents 7f4189c + 73a72ef commit 2a0ebf4
Show file tree
Hide file tree
Showing 22 changed files with 43 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/addons/mod/assign/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import { CoreConstants, ModPurpose } from '@/core/constants';
import { Injectable, Type } from '@angular/core';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { AddonModAssignIndexComponent } from '../../components/index';
import { makeSingleton } from '@singletons';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';

Expand Down Expand Up @@ -51,6 +50,8 @@ export class AddonModAssignModuleHandlerService extends CoreModuleHandlerBase im
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown> | undefined> {
const { AddonModAssignIndexComponent } = await import('../../components/index');

return AddonModAssignIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/book/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

import { Injectable, Type } from '@angular/core';
import { AddonModBookIndexComponent } from '../../components/index';
import { AddonModBook } from '../book';
import { CoreConstants, ModPurpose } from '@/core/constants';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
Expand Down Expand Up @@ -56,6 +55,8 @@ export class AddonModBookModuleHandlerService extends CoreModuleHandlerBase impl
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown> | undefined> {
const { AddonModBookIndexComponent } = await import('../../components/index');

return AddonModBookIndexComponent;
}

Expand Down
2 changes: 1 addition & 1 deletion src/addons/mod/chat/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class AddonModChatModuleHandlerService extends CoreModuleHandlerBase impl
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModChatIndexComponent } = await import('@addons/mod/chat/components/index');
const { AddonModChatIndexComponent } = await import('../../components/index');

return AddonModChatIndexComponent;
}
Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/choice/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons';
import { AddonModChoiceIndexComponent } from '../../components/index';

/**
* Handler to support choice modules.
Expand Down Expand Up @@ -48,6 +47,8 @@ export class AddonModChoiceModuleHandlerService extends CoreModuleHandlerBase im
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModChoiceIndexComponent } = await import('../../components/index');

return AddonModChoiceIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/data/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons';
import { AddonModDataIndexComponent } from '../../components/index';

/**
* Handler to support data modules.
Expand Down Expand Up @@ -50,6 +49,8 @@ export class AddonModDataModuleHandlerService extends CoreModuleHandlerBase impl
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModDataIndexComponent } = await import('../../components/index');

return AddonModDataIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/feedback/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { CoreConstants, ModPurpose } from '@/core/constants';
import { Injectable, Type } from '@angular/core';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons';
import { AddonModFeedbackIndexComponent } from '../../components/index';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';

/**
Expand Down Expand Up @@ -48,6 +47,8 @@ export class AddonModFeedbackModuleHandlerService extends CoreModuleHandlerBase
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModFeedbackIndexComponent } = await import('../../components/index');

return AddonModFeedbackIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/folder/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/
import { CoreNavigator } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons';
import { AddonModFolderIndexComponent } from '../../components/index';

/**
* Handler to support folder modules.
Expand Down Expand Up @@ -86,6 +85,8 @@ export class AddonModFolderModuleHandlerService extends CoreModuleHandlerBase im
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown> | undefined> {
const { AddonModFolderIndexComponent } = await import('../../components/index');

return AddonModFolderIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/glossary/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons';
import { AddonModGlossaryIndexComponent } from '../../components/index/index';

/**
* Handler to support glossary modules.
Expand Down Expand Up @@ -50,6 +49,8 @@ export class AddonModGlossaryModuleHandlerService extends CoreModuleHandlerBase
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModGlossaryIndexComponent } = await import('../../components/index');

return AddonModGlossaryIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/h5pactivity/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons';
import { AddonModH5PActivityIndexComponent } from '../../components/index';
import { AddonModH5PActivity } from '../h5pactivity';

/**
Expand Down Expand Up @@ -56,6 +55,8 @@ export class AddonModH5PActivityModuleHandlerService extends CoreModuleHandlerBa
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModH5PActivityIndexComponent } = await import('../../components/index');

return AddonModH5PActivityIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/imscp/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons';
import { AddonModImscpIndexComponent } from '../../components/index';
import { AddonModImscp } from '../imscp';

/**
Expand Down Expand Up @@ -56,6 +55,8 @@ export class AddonModImscpModuleHandlerService extends CoreModuleHandlerBase imp
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModImscpIndexComponent } = await import('../../components/index');

return AddonModImscpIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/lesson/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { Injectable, Type } from '@angular/core';

import { CoreConstants, ModPurpose } from '@/core/constants';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { AddonModLessonIndexComponent } from '../../components/index';
import { makeSingleton } from '@singletons';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';

Expand Down Expand Up @@ -49,6 +48,8 @@ export class AddonModLessonModuleHandlerService extends CoreModuleHandlerBase im
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModLessonIndexComponent } = await import('../../components/index');

return AddonModLessonIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/lti/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/
import { CoreCourseModuleData } from '@features/course/services/course-helper';
import { makeSingleton } from '@singletons';
import { AddonModLtiHelper } from '../lti-helper';
import { AddonModLtiIndexComponent } from '../../components/index';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourse } from '@features/course/services/course';

Expand Down Expand Up @@ -76,6 +75,8 @@ export class AddonModLtiModuleHandlerService extends CoreModuleHandlerBase imple
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModLtiIndexComponent } = await import('../../components/index');

return AddonModLtiIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/page/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { Injectable, Type } from '@angular/core';
import { AddonModPage } from '../page';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { CoreConstants, ModPurpose } from '@/core/constants';
import { AddonModPageIndexComponent } from '../../components/index';
import { makeSingleton } from '@singletons';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';

Expand Down Expand Up @@ -56,6 +55,8 @@ export class AddonModPageModuleHandlerService extends CoreModuleHandlerBase impl
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModPageIndexComponent } = await import('../../components/index');

return AddonModPageIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/quiz/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { Injectable, Type } from '@angular/core';

import { CoreConstants, ModPurpose } from '@/core/constants';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { AddonModQuizIndexComponent } from '../../components/index';
import { makeSingleton } from '@singletons';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';

Expand Down Expand Up @@ -51,6 +50,8 @@ export class AddonModQuizModuleHandlerService extends CoreModuleHandlerBase impl
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModQuizIndexComponent } = await import('../../components/index');

return AddonModQuizIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/resource/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { CoreCourseModulePrefetchDelegate } from '@features/course/services/modu
import { CoreFileHelper } from '@services/file-helper';
import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { makeSingleton, Translate } from '@singletons';
import { AddonModResourceIndexComponent } from '../../components/index';
import { AddonModResource } from '../resource';
import { AddonModResourceHelper } from '../resource-helper';
import { CoreUtils } from '@services/utils/utils';
Expand Down Expand Up @@ -167,6 +166,8 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModResourceIndexComponent } = await import('../../components/index');

return AddonModResourceIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/scorm/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons';
import { AddonModScormIndexComponent } from '../../components/index';

/**
* Handler to support SCORM modules.
Expand Down Expand Up @@ -48,6 +47,8 @@ export class AddonModScormModuleHandlerService extends CoreModuleHandlerBase imp
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModScormIndexComponent } = await import('../../components/index');

return AddonModScormIndexComponent;
}

Expand Down
2 changes: 1 addition & 1 deletion src/addons/mod/survey/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class AddonModSurveyModuleHandlerService extends CoreModuleHandlerBase im
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModSurveyIndexComponent } = await import('@addons/mod/survey/components/index');
const { AddonModSurveyIndexComponent } = await import('../../components/index');

return AddonModSurveyIndexComponent;
}
Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/url/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { CoreNavigationOptions } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { AddonModUrlIndexComponent } from '../../components/index/index';
import { AddonModUrl } from '../url';
import { AddonModUrlHelper } from '../url-helper';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
Expand Down Expand Up @@ -190,6 +189,8 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModUrlIndexComponent } = await import('../../components/index');

return AddonModUrlIndexComponent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/addons/mod/wiki/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons';
import { AddonModWikiIndexComponent } from '../../components/index';

/**
* Handler to support wiki modules.
Expand Down Expand Up @@ -49,6 +48,8 @@ export class AddonModWikiModuleHandlerService extends CoreModuleHandlerBase impl
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModWikiIndexComponent } = await import('../../components/index');

return AddonModWikiIndexComponent;
}

Expand Down
2 changes: 1 addition & 1 deletion src/addons/mod/workshop/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class AddonModWorkshopModuleHandlerService extends CoreModuleHandlerBase
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { AddonModWorkshopIndexComponent } = await import('@addons/mod/workshop/components/index');
const { AddonModWorkshopIndexComponent } = await import('../../components/index');

return AddonModWorkshopIndexComponent;
}
Expand Down
4 changes: 3 additions & 1 deletion src/core/features/course/services/handlers/default-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { CoreSites } from '@services/sites';
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '../module-delegate';
import { CoreCourse } from '../course';
import { CoreCourseModuleData } from '../course-helper';
import { CoreCourseUnsupportedModuleComponent } from '@features/course/components/unsupported-module/unsupported-module';
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';

/**
Expand Down Expand Up @@ -79,6 +78,9 @@ export class CoreCourseModuleDefaultHandler implements CoreCourseModuleHandler {
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { CoreCourseUnsupportedModuleComponent } =
await import('@features/course/components/unsupported-module/unsupported-module');

return CoreCourseUnsupportedModuleComponent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { CoreConstants } from '@/core/constants';
import { CoreCourse } from '@features/course/services/course';
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
import { CoreSitePluginsModuleIndexComponent } from '@features/siteplugins/components/module-index/module-index';
import {
CoreSitePlugins,
CoreSitePluginsContent,
Expand Down Expand Up @@ -205,6 +204,9 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp
* @inheritdoc
*/
async getMainComponent(): Promise<Type<unknown>> {
const { CoreSitePluginsModuleIndexComponent } =
await import('@features/siteplugins/components/module-index/module-index');

return CoreSitePluginsModuleIndexComponent;
}

Expand Down

0 comments on commit 2a0ebf4

Please sign in to comment.