MOBILE-2502 course: Don't get sections using cache key

main
dpalou 2018-10-15 11:33:35 +02:00
parent f56b7cfd3c
commit 98c4eba988
1 changed files with 8 additions and 2 deletions

View File

@ -516,7 +516,6 @@ export class CoreCourseProvider {
return this.sitesProvider.getSite(siteId).then((site) => { return this.sitesProvider.getSite(siteId).then((site) => {
preSets = preSets || {}; preSets = preSets || {};
preSets.cacheKey = this.getSectionsCacheKey(courseId); preSets.cacheKey = this.getSectionsCacheKey(courseId);
preSets.getCacheUsingCacheKey = true; // This is to make sure users don't lose offline access when updating.
const params = { const params = {
courseid: courseId, courseid: courseId,
@ -536,7 +535,14 @@ export class CoreCourseProvider {
] ]
}; };
return site.read('core_course_get_contents', params, preSets).then((sections) => { return site.read('core_course_get_contents', params, preSets).catch(() => {
// Error getting the data, it could fail because we added a new parameter and the call isn't cached.
// Retry without the new parameter and forcing cache.
preSets.omitExpires = true;
params.options.splice(-1, 1);
return site.read('core_course_get_contents', params, preSets);
}).then((sections) => {
const siteHomeId = site.getSiteHomeId(); const siteHomeId = site.getSiteHomeId();
let showSections = true; let showSections = true;