diff --git a/src/core/features/course/services/module-prefetch-delegate.ts b/src/core/features/course/services/module-prefetch-delegate.ts index 845e2c99f..5451cb139 100644 --- a/src/core/features/course/services/module-prefetch-delegate.ts +++ b/src/core/features/course/services/module-prefetch-delegate.ts @@ -122,8 +122,8 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { try { - const data = await this.getModuleStatusAndDownloadTime(module, courseId); - if (data.status != CoreConstants.DOWNLOADED) { + const data = await this.getModuleDownloadTime(module); + if (!data.downloadTime || data.outdated) { return; } @@ -730,22 +730,20 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { + ): Promise<{ downloadTime?: number; outdated?: boolean }> { const handler = this.getPrefetchHandlerFor(module.modname); const siteId = CoreSites.getCurrentSiteId(); if (!handler) { - // No handler found, module not downloadable. - return { status: CoreConstants.NOT_DOWNLOADABLE }; + return {}; } // Get the status from the cache. @@ -753,14 +751,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate(packageId, 'status'); if (status !== undefined && !CoreFileHelper.isStateDownloaded(status)) { - // Module isn't downloaded, just return the status. - return { status }; - } - - // Check if the module is downloadable. - const downloadable = await this.isModuleDownloadable(module, courseId); - if (!downloadable) { - return { status: CoreConstants.NOT_DOWNLOADABLE }; + return {}; } try { @@ -768,11 +759,11 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate