forked from CIT/Vmeda.Online
		
	Merge pull request #1399 from dpalou/MOBILE-2466
MOBILE-2466 course: Fix calculate and download sections
This commit is contained in:
		
						commit
						bfd4e9c936
					
				| @ -181,7 +181,8 @@ export class CoreCourseHelperProvider { | |||||||
| 
 | 
 | ||||||
|             // Set this section data.
 |             // Set this section data.
 | ||||||
|             section.showDownload = result.status === CoreConstants.NOT_DOWNLOADED; |             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)) { |             if (result.status !== CoreConstants.DOWNLOADING || !this.prefetchDelegate.isBeingDownloaded(section.id)) { | ||||||
|                 section.isDownloading = false; |                 section.isDownloading = false; | ||||||
| @ -232,7 +233,8 @@ export class CoreCourseHelperProvider { | |||||||
|             if (allSectionsSection) { |             if (allSectionsSection) { | ||||||
|                 // Set "All sections" data.
 |                 // Set "All sections" data.
 | ||||||
|                 allSectionsSection.showDownload = allSectionsStatus === CoreConstants.NOT_DOWNLOADED; |                 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; |                 allSectionsSection.isDownloading = allSectionsStatus === CoreConstants.DOWNLOADING; | ||||||
|             } |             } | ||||||
|         }).finally(() => { |         }).finally(() => { | ||||||
| @ -1090,7 +1092,8 @@ export class CoreCourseHelperProvider { | |||||||
|             return this.utils.allPromises(promises).then(() => { |             return this.utils.allPromises(promises).then(() => { | ||||||
|                 // Set "All sections" data.
 |                 // Set "All sections" data.
 | ||||||
|                 section.showDownload = allSectionsStatus === CoreConstants.NOT_DOWNLOADED; |                 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; |                 section.isDownloading = allSectionsStatus === CoreConstants.DOWNLOADING; | ||||||
|             }).finally(() => { |             }).finally(() => { | ||||||
|                 section.isDownloading = false; |                 section.isDownloading = false; | ||||||
|  | |||||||
| @ -702,7 +702,7 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate { | |||||||
|                         promise = this.getCourseUpdatesByCourseId(courseId); |                         promise = this.getCourseUpdatesByCourseId(courseId); | ||||||
|                     } else if (updates === false) { |                     } else if (updates === false) { | ||||||
|                         // Cannot check updates.
 |                         // Cannot check updates.
 | ||||||
|                         return Promise.resolve(); |                         return status; | ||||||
|                     } else { |                     } else { | ||||||
|                         promise = Promise.resolve(updates); |                         promise = Promise.resolve(updates); | ||||||
|                     } |                     } | ||||||
| @ -803,7 +803,7 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate { | |||||||
|                             result.total++; |                             result.total++; | ||||||
|                         } |                         } | ||||||
|                     }).catch((error) => { |                     }).catch((error) => { | ||||||
|                         let cacheStatus = this.statusCache.getValue(packageId, 'status', true); |                         const cacheStatus = this.statusCache.getValue(packageId, 'status', true); | ||||||
|                         if (typeof cacheStatus == 'undefined') { |                         if (typeof cacheStatus == 'undefined') { | ||||||
|                             return Promise.reject(error); |                             return Promise.reject(error); | ||||||
|                         } |                         } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user