MOBILE-2873 course: Invalidate data after sync before prefetch
parent
7f32b2763a
commit
4f1cd6a94e
|
@ -1168,7 +1168,12 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate {
|
||||||
*/
|
*/
|
||||||
syncModules(modules: any[], courseId: number): Promise<any> {
|
syncModules(modules: any[], courseId: number): Promise<any> {
|
||||||
return Promise.all(modules.map((module) => {
|
return Promise.all(modules.map((module) => {
|
||||||
return this.syncModule(module, courseId);
|
return this.syncModule(module, courseId).then(() => {
|
||||||
|
// Invalidate course updates.
|
||||||
|
return this.invalidateCourseUpdates(courseId).catch(() => {
|
||||||
|
// Ignore errors.
|
||||||
|
});
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1182,13 +1187,20 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate {
|
||||||
syncModule(module: any, courseId: number): Promise<any> {
|
syncModule(module: any, courseId: number): Promise<any> {
|
||||||
const handler = this.getPrefetchHandlerFor(module);
|
const handler = this.getPrefetchHandlerFor(module);
|
||||||
|
|
||||||
const promise = handler && handler.sync ? handler.sync(module, courseId) : Promise.resolve();
|
if (handler && handler.sync) {
|
||||||
|
return handler.sync(module, courseId).then((result) => {
|
||||||
|
// Always invalidate status cache for this module. We cannot know if data was sent to server or not.
|
||||||
|
this.invalidateModuleStatusCache(module);
|
||||||
|
|
||||||
return promise.catch(() => {
|
return result;
|
||||||
|
}).catch(() => {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefetches a list of modules using their prefetch handlers.
|
* Prefetches a list of modules using their prefetch handlers.
|
||||||
* If a prefetch already exists for this site and id, returns the current promise.
|
* If a prefetch already exists for this site and id, returns the current promise.
|
||||||
|
|
Loading…
Reference in New Issue