forked from EVOgeek/Vmeda.Online
		
	MOBILE-4539 course: Don't call isDownloadable to check module updates
This commit is contained in:
		
							parent
							
								
									1c93299467
								
							
						
					
					
						commit
						2533829030
					
				| @ -122,8 +122,8 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo | |||||||
| 
 | 
 | ||||||
|         const promises = modules.map(async (module) => { |         const promises = modules.map(async (module) => { | ||||||
|             try { |             try { | ||||||
|                 const data = await this.getModuleStatusAndDownloadTime(module, courseId); |                 const data = await this.getModuleDownloadTime(module); | ||||||
|                 if (data.status != CoreConstants.DOWNLOADED) { |                 if (!data.downloadTime || data.outdated) { | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
| @ -730,22 +730,20 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Get a module status and download time. It will only return the download time if the module is downloaded or outdated. |      * Get the time a module was downloaded, and whether the download is outdated. | ||||||
|  |      * It will only return the download time if the module is downloaded or outdated. | ||||||
|      * |      * | ||||||
|      * @param module Module. |      * @param module Module. | ||||||
|      * @param courseId Course ID the module belongs to. |  | ||||||
|      * @returns Promise resolved with the data. |      * @returns Promise resolved with the data. | ||||||
|      */ |      */ | ||||||
|     protected async getModuleStatusAndDownloadTime( |     protected async getModuleDownloadTime( | ||||||
|         module: CoreCourseAnyModuleData, |         module: CoreCourseAnyModuleData, | ||||||
|         courseId: number, |     ): Promise<{ downloadTime?: number; outdated?: boolean }> { | ||||||
|     ): Promise<{ status: string; downloadTime?: number }> { |  | ||||||
|         const handler = this.getPrefetchHandlerFor(module.modname); |         const handler = this.getPrefetchHandlerFor(module.modname); | ||||||
|         const siteId = CoreSites.getCurrentSiteId(); |         const siteId = CoreSites.getCurrentSiteId(); | ||||||
| 
 | 
 | ||||||
|         if (!handler) { |         if (!handler) { | ||||||
|             // No handler found, module not downloadable.
 |             return {}; | ||||||
|             return { status: CoreConstants.NOT_DOWNLOADABLE }; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Get the status from the cache.
 |         // Get the status from the cache.
 | ||||||
| @ -753,14 +751,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo | |||||||
|         const status = this.statusCache.getValue<string>(packageId, 'status'); |         const status = this.statusCache.getValue<string>(packageId, 'status'); | ||||||
| 
 | 
 | ||||||
|         if (status !== undefined && !CoreFileHelper.isStateDownloaded(status)) { |         if (status !== undefined && !CoreFileHelper.isStateDownloaded(status)) { | ||||||
|             // Module isn't downloaded, just return the status.
 |             return {}; | ||||||
|             return { status }; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         // Check if the module is downloadable.
 |  | ||||||
|         const downloadable = await this.isModuleDownloadable(module, courseId); |  | ||||||
|         if (!downloadable) { |  | ||||||
|             return { status: CoreConstants.NOT_DOWNLOADABLE }; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
| @ -768,11 +759,11 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo | |||||||
|             const data = await CoreFilepool.getPackageData(siteId, handler.component, module.id); |             const data = await CoreFilepool.getPackageData(siteId, handler.component, module.id); | ||||||
| 
 | 
 | ||||||
|             return { |             return { | ||||||
|                 status: data.status || CoreConstants.NOT_DOWNLOADED, |                 downloadTime: data.downloadTime, | ||||||
|                 downloadTime: data.downloadTime || 0, |                 outdated: data.status === CoreConstants.OUTDATED, | ||||||
|             }; |             }; | ||||||
|         } catch { |         } catch { | ||||||
|             return { status: CoreConstants.NOT_DOWNLOADED }; |             return {}; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -795,8 +786,8 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo | |||||||
| 
 | 
 | ||||||
|         const site = await CoreSites.getSite(siteId); |         const site = await CoreSites.getSite(siteId); | ||||||
| 
 | 
 | ||||||
|         const data = await this.getModuleStatusAndDownloadTime(module, courseId); |         const data = await this.getModuleDownloadTime(module); | ||||||
|         if (!CoreFileHelper.isStateDownloaded(data.status)) { |         if (!data.downloadTime) { | ||||||
|             // Not downloaded, no updates.
 |             // Not downloaded, no updates.
 | ||||||
|             return null; |             return null; | ||||||
|         } |         } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user