MOBILE-2701 resource: Always show refresh for external files

main
Dani Palou 2018-11-27 03:39:04 +01:00
parent 601508aefc
commit da799faf6e
2 changed files with 22 additions and 1 deletions

View File

@ -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.
*

View File

@ -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(() => {