From 03f573b63f3a76642983459ee32947bd363a0ed7 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Tue, 21 Dec 2021 16:23:57 +0100 Subject: [PATCH] MOBILE-3833 core: Fix resolving prefetch handlers --- .../course/components/module/module.ts | 2 +- .../features/course/services/course-helper.ts | 4 +-- .../services/module-prefetch-delegate.ts | 36 +++++++++---------- .../components/module-index/module-index.ts | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/core/features/course/components/module/module.ts b/src/core/features/course/components/module/module.ts index 944eed73a..82df87061 100644 --- a/src/core/features/course/components/module/module.ts +++ b/src/core/features/course/components/module/module.ts @@ -106,7 +106,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { if (this.module.handlerData.showDownloadButton) { // Listen for changes on this module status, even if download isn't enabled. - this.prefetchHandler = CoreCourseModulePrefetchDelegate.getPrefetchHandlerFor(this.module.name); + this.prefetchHandler = CoreCourseModulePrefetchDelegate.getPrefetchHandlerFor(this.module.modname); this.statusObserver = CoreEvents.on(CoreEvents.PACKAGE_STATUS_CHANGED, (data) => { if (!this.module || data.componentId != this.module.id || !this.prefetchHandler || diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts index 4162eb2b4..071faa626 100644 --- a/src/core/features/course/services/course-helper.ts +++ b/src/core/features/course/services/course-helper.ts @@ -1013,7 +1013,7 @@ export class CoreCourseHelperProvider { ): Promise { siteId = siteId || CoreSites.getCurrentSiteId(); - const prefetchHandler = CoreCourseModulePrefetchDelegate.getPrefetchHandlerFor(module.name); + const prefetchHandler = CoreCourseModulePrefetchDelegate.getPrefetchHandlerFor(module.modname); if (prefetchHandler) { // Use the prefetch handler to download the module. @@ -2048,7 +2048,7 @@ export class CoreCourseHelperProvider { promises.push(CoreCourseModulePrefetchDelegate.removeModuleFiles(module, courseId)); - const handler = CoreCourseModulePrefetchDelegate.getPrefetchHandlerFor(module.name); + const handler = CoreCourseModulePrefetchDelegate.getPrefetchHandlerFor(module.modname); const site = CoreSites.getCurrentSite(); if (handler && site) { promises.push(site.deleteComponentFromCache(handler.component, module.id)); diff --git a/src/core/features/course/services/module-prefetch-delegate.ts b/src/core/features/course/services/module-prefetch-delegate.ts index a2998f6d7..31984758f 100644 --- a/src/core/features/course/services/module-prefetch-delegate.ts +++ b/src/core/features/course/services/module-prefetch-delegate.ts @@ -95,7 +95,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); if (!handler) { // Module not supported, cannot use check updates. @@ -171,7 +171,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { // Check if the module has a prefetch handler. - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); if (!handler) { return; @@ -381,7 +381,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); if (!handler) { return { size: 0, total: false }; @@ -419,7 +419,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); if (!handler) { return 0; } @@ -492,7 +492,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); if (handler?.getFiles) { // The handler defines a function to get files, use it. @@ -548,7 +548,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); if (!handler) { // No handler found, module not downloadable. @@ -712,7 +712,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); if (!handler || (onlyToDisplay && handler.skipListStatus)) { return; } @@ -758,7 +758,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); const siteId = CoreSites.getCurrentSiteId(); if (!handler) { @@ -895,7 +895,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { const promises = modules.map(async (module) => { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); if (!handler) { return; } @@ -919,7 +919,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); const moduleUpdates = updates[module.id]; if (handler?.hasUpdates) { @@ -1033,7 +1033,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); if (!handler) { return; } @@ -1067,7 +1067,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate(module: CoreCourseAnyModuleData, courseId: number): Promise { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); if (!handler?.sync) { return; } @@ -1124,7 +1124,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { // Check if the module has a prefetch handler. - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); if (!handler) { return; } @@ -1170,7 +1170,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - const handler = this.getPrefetchHandlerFor(module.name); + const handler = this.getPrefetchHandlerFor(module.modname); const siteId = CoreSites.getCurrentSiteId(); if (handler?.removeFiles) { diff --git a/src/core/features/siteplugins/components/module-index/module-index.ts b/src/core/features/siteplugins/components/module-index/module-index.ts index a4cab3943..7b8d9311e 100644 --- a/src/core/features/siteplugins/components/module-index/module-index.ts +++ b/src/core/features/siteplugins/components/module-index/module-index.ts @@ -145,7 +145,7 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C this.refreshIcon = CoreConstants.ICON_REFRESH; // Check if there is a prefetch handler for this type of module. - if (CoreCourseModulePrefetchDelegate.getPrefetchHandlerFor(this.module.name)) { + if (CoreCourseModulePrefetchDelegate.getPrefetchHandlerFor(this.module.modname)) { CoreCourseHelper.fillContextMenu(this, this.module, this.courseId, refresh, this.component); } }