Merge pull request #1399 from dpalou/MOBILE-2466

MOBILE-2466 course: Fix calculate and download sections
main
Juan Leyva 2018-07-05 16:06:12 +02:00 committed by GitHub
commit bfd4e9c936
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -181,7 +181,8 @@ export class CoreCourseHelperProvider {
// Set this section data.
section.showDownload = result.status === CoreConstants.NOT_DOWNLOADED;
section.showRefresh = result.status === CoreConstants.OUTDATED;
section.showRefresh = result.status === CoreConstants.OUTDATED ||
(!this.prefetchDelegate.canCheckUpdates() && result.status === CoreConstants.DOWNLOADED);
if (result.status !== CoreConstants.DOWNLOADING || !this.prefetchDelegate.isBeingDownloaded(section.id)) {
section.isDownloading = false;
@ -232,7 +233,8 @@ export class CoreCourseHelperProvider {
if (allSectionsSection) {
// Set "All sections" data.
allSectionsSection.showDownload = allSectionsStatus === CoreConstants.NOT_DOWNLOADED;
allSectionsSection.showRefresh = allSectionsStatus === CoreConstants.OUTDATED;
allSectionsSection.showRefresh = allSectionsStatus === CoreConstants.OUTDATED ||
(!this.prefetchDelegate.canCheckUpdates() && allSectionsStatus === CoreConstants.DOWNLOADED);
allSectionsSection.isDownloading = allSectionsStatus === CoreConstants.DOWNLOADING;
}
}).finally(() => {
@ -1090,7 +1092,8 @@ export class CoreCourseHelperProvider {
return this.utils.allPromises(promises).then(() => {
// Set "All sections" data.
section.showDownload = allSectionsStatus === CoreConstants.NOT_DOWNLOADED;
section.showRefresh = allSectionsStatus === CoreConstants.OUTDATED;
section.showRefresh = allSectionsStatus === CoreConstants.OUTDATED ||
(!this.prefetchDelegate.canCheckUpdates() && allSectionsStatus === CoreConstants.DOWNLOADED);
section.isDownloading = allSectionsStatus === CoreConstants.DOWNLOADING;
}).finally(() => {
section.isDownloading = false;

View File

@ -702,7 +702,7 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate {
promise = this.getCourseUpdatesByCourseId(courseId);
} else if (updates === false) {
// Cannot check updates.
return Promise.resolve();
return status;
} else {
promise = Promise.resolve(updates);
}
@ -803,7 +803,7 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate {
result.total++;
}
}).catch((error) => {
let cacheStatus = this.statusCache.getValue(packageId, 'status', true);
const cacheStatus = this.statusCache.getValue(packageId, 'status', true);
if (typeof cacheStatus == 'undefined') {
return Promise.reject(error);
}