forked from CIT/Vmeda.Online
		
	MOBILE-2873 course: Invalidate data after sync before prefetch
This commit is contained in:
		
							parent
							
								
									7f32b2763a
								
							
						
					
					
						commit
						4f1cd6a94e
					
				| @ -1168,7 +1168,12 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate { | ||||
|      */ | ||||
|     syncModules(modules: any[], courseId: number): Promise<any> { | ||||
|         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> { | ||||
|         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.
 | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         return Promise.resolve(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Prefetches a list of modules using their prefetch handlers. | ||||
|      * If a prefetch already exists for this site and id, returns the current promise. | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user