From da799faf6e44e052a6d1f60353a0bb011890bae5 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 27 Nov 2018 03:39:04 +0100 Subject: [PATCH] MOBILE-2701 resource: Always show refresh for external files --- .../resource/providers/prefetch-handler.ts | 21 +++++++++++++++++++ src/providers/filepool.ts | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/addon/mod/resource/providers/prefetch-handler.ts b/src/addon/mod/resource/providers/prefetch-handler.ts index 30b75932b..842687717 100644 --- a/src/addon/mod/resource/providers/prefetch-handler.ts +++ b/src/addon/mod/resource/providers/prefetch-handler.ts @@ -23,6 +23,7 @@ import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreCourseResourcePrefetchHandlerBase } from '@core/course/classes/resource-prefetch-handler'; import { AddonModResourceProvider } from './resource'; import { AddonModResourceHelperProvider } from './helper'; +import { CoreConstants } from '@core/constants'; /** * Handler to prefetch resources. @@ -41,6 +42,26 @@ export class AddonModResourcePrefetchHandler extends CoreCourseResourcePrefetchH super(translate, appProvider, utils, courseProvider, filepoolProvider, sitesProvider, domUtils); } + /** + * Return the status to show based on current status. + * + * @param {any} module Module. + * @param {string} status The current status. + * @param {boolean} canCheck Whether the site allows checking for updates. + * @return {string} Status to display. + */ + determineStatus(module: any, status: string, canCheck: boolean): string { + if (status == CoreConstants.DOWNLOADED && module && module.contents) { + // If the first file is an external file, always display the module as outdated. + const mainFile = module.contents[0]; + if (mainFile && mainFile.isexternalfile) { + return CoreConstants.OUTDATED; + } + } + + return status; + } + /** * Download or prefetch the content. * diff --git a/src/providers/filepool.ts b/src/providers/filepool.ts index 3074fd91f..e01deba92 100644 --- a/src/providers/filepool.ts +++ b/src/providers/filepool.ts @@ -2501,7 +2501,7 @@ export class CoreFilepoolProvider { // File not in pool. }).then((entry: CoreFilepoolFileEntry) => { - if (entry && !this.isFileOutdated(entry, options.revision, options.timemodified)) { + if (entry && !options.isexternalfile && !this.isFileOutdated(entry, options.revision, options.timemodified)) { // We have the file, it is not stale, we can update links and remove from queue. this.logger.debug('Queued file already in store, ignoring...'); this.addFileLinks(siteId, fileId, links).catch(() => {