diff --git a/src/addons/mod/feedback/services/feedback-sync.ts b/src/addons/mod/feedback/services/feedback-sync.ts index bdfe3d355..291cb4338 100644 --- a/src/addons/mod/feedback/services/feedback-sync.ts +++ b/src/addons/mod/feedback/services/feedback-sync.ts @@ -51,7 +51,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv courseId: number, regex?: RegExp, siteId?: string, - ): Promise { + ): Promise { regex = regex || /^.*files$|^timers/; return super.prefetchAfterUpdate(prefetchHandler, module, courseId, regex, siteId); diff --git a/src/addons/mod/survey/components/index/index.ts b/src/addons/mod/survey/components/index/index.ts index 28845b771..73999cf7a 100644 --- a/src/addons/mod/survey/components/index/index.ts +++ b/src/addons/mod/survey/components/index/index.ts @@ -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); diff --git a/src/core/features/course/classes/activity-sync.ts b/src/core/features/course/classes/activity-sync.ts index 8cebdddd6..50a8feccd 100644 --- a/src/core/features/course/classes/activity-sync.ts +++ b/src/core/features/course/classes/activity-sync.ts @@ -31,7 +31,7 @@ export class CoreCourseActivitySyncBaseProvider 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 extends CoreSyncBasePr courseId: number, preventDownloadRegex?: RegExp, siteId?: string, - ): Promise { + ): Promise { // 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 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; } /**