forked from EVOgeek/Vmeda.Online
		
	MOBILE-4069 survey: Fix survey behats
This commit is contained in:
		
							parent
							
								
									9a5231d481
								
							
						
					
					
						commit
						ab39251a0f
					
				| @ -51,7 +51,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv | ||||
|         courseId: number, | ||||
|         regex?: RegExp, | ||||
|         siteId?: string, | ||||
|     ): Promise<void> { | ||||
|     ): Promise<boolean> { | ||||
|         regex = regex || /^.*files$|^timers/; | ||||
| 
 | ||||
|         return super.prefetchAfterUpdate(prefetchHandler, module, courseId, regex, siteId); | ||||
|  | ||||
| @ -205,21 +205,23 @@ export class AddonModSurveyIndexComponent extends CoreCourseModuleMainActivityCo | ||||
|             if (online && this.isPrefetched()) { | ||||
|                 // The survey is downloaded, update the data.
 | ||||
|                 try { | ||||
|                     await AddonModSurveySync.prefetchAfterUpdate( | ||||
|                     const prefetched = await AddonModSurveySync.prefetchAfterUpdate( | ||||
|                         AddonModSurveyPrefetchHandler.instance, | ||||
|                         this.module, | ||||
|                         this.courseId, | ||||
|                     ); | ||||
| 
 | ||||
|                     // Update the view.
 | ||||
|                     this.showLoadingAndFetch(false, false); | ||||
|                     prefetched ? | ||||
|                         this.showLoadingAndFetch(false, false) : | ||||
|                         this.showLoadingAndRefresh(false);; | ||||
|                 } catch { | ||||
|                     // Prefetch failed, refresh the data.
 | ||||
|                     await this.showLoadingAndRefresh(false); | ||||
|                     this.showLoadingAndRefresh(false); | ||||
|                 } | ||||
|             } else { | ||||
|                 // Not downloaded, refresh the data.
 | ||||
|                 await this.showLoadingAndRefresh(false); | ||||
|                 this.showLoadingAndRefresh(false); | ||||
|             } | ||||
|         } catch (error) { | ||||
|             CoreDomUtils.showErrorModalDefault(error, 'addon.mod_survey.cannotsubmitsurvey', true); | ||||
|  | ||||
| @ -31,7 +31,7 @@ export class CoreCourseActivitySyncBaseProvider<T = void> extends CoreSyncBasePr | ||||
|      * @param courseId Course ID. | ||||
|      * @param preventDownloadRegex If regex matches, don't download the data. Defaults to check files. | ||||
|      * @param siteId Site ID. If not defined, current site. | ||||
|      * @return Promise resolved when done. | ||||
|      * @return Promise resolved with boolean: true if prefetched, false if no need to prefetch. | ||||
|      */ | ||||
|     async prefetchAfterUpdate( | ||||
|         prefetchHandler: CoreCourseModulePrefetchHandlerBase, | ||||
| @ -39,12 +39,12 @@ export class CoreCourseActivitySyncBaseProvider<T = void> extends CoreSyncBasePr | ||||
|         courseId: number, | ||||
|         preventDownloadRegex?: RegExp, | ||||
|         siteId?: string, | ||||
|     ): Promise<void> { | ||||
|     ): Promise<boolean> { | ||||
|         // Get the module updates to check if the data was updated or not.
 | ||||
|         const result = await CoreCourseModulePrefetchDelegate.getModuleUpdates(module, courseId, true, siteId); | ||||
| 
 | ||||
|         if (!result?.updates.length) { | ||||
|             return; | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         // Only prefetch if files haven't changed, to prevent downloading too much data automatically.
 | ||||
| @ -52,8 +52,12 @@ export class CoreCourseActivitySyncBaseProvider<T = void> extends CoreSyncBasePr | ||||
|         const shouldDownload = !result.updates.find((entry) => entry.name.match(regex)); | ||||
| 
 | ||||
|         if (shouldDownload) { | ||||
|             return prefetchHandler.download(module, courseId); | ||||
|             await prefetchHandler.download(module, courseId); | ||||
| 
 | ||||
|             return true; | ||||
|         } | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user