MOBILE-2675 prefetch: Prefetch module info to be able to handle links
parent
d4b3496f79
commit
d2c82f25dd
|
@ -230,8 +230,6 @@ export class AddonModAssignPrefetchHandler extends CoreCourseActivityPrefetchHan
|
|||
|
||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||
|
||||
promises.push(this.courseProvider.getModuleBasicInfo(module.id, siteId));
|
||||
|
||||
// Get assignment to retrieve all its submissions.
|
||||
promises.push(this.assignProvider.getAssignment(courseId, module.id, siteId).then((assign) => {
|
||||
const subPromises = [],
|
||||
|
|
|
@ -358,9 +358,6 @@ export class AddonModLessonPrefetchHandler extends CoreCourseActivityPrefetchHan
|
|||
// Prefetch question attempts in last retake for offline calculations.
|
||||
promises.push(this.lessonProvider.getQuestionsAttemptsOnline(lesson.id, retake, false, undefined, false, true, siteId));
|
||||
|
||||
// Get module info to be able to handle links.
|
||||
promises.push(this.courseProvider.getModuleBasicInfo(module.id, siteId));
|
||||
|
||||
if (accessInfo.canviewreports) {
|
||||
// Prefetch reports data.
|
||||
promises.push(this.groupsProvider.getActivityAllowedGroupsIfEnabled(module.id, undefined, siteId).then((groups) => {
|
||||
|
|
|
@ -70,11 +70,6 @@ export class AddonModResourcePrefetchHandler extends CoreCourseResourcePrefetchH
|
|||
promises.push(this.resourceProvider.getResourceData(courseId, module.id));
|
||||
}
|
||||
|
||||
/* When prefetching we usually use ignoreCache=true. However, this WS call can return a lot of data, so if
|
||||
a user downloads resources 1 by 1 we would be downloading the same data over and over again. Since
|
||||
this data won't change often it's probably better to use ignoreCache=false. */
|
||||
promises.push(this.courseProvider.getModule(module.id, courseId, undefined, false, false, undefined, this.modName));
|
||||
|
||||
return Promise.all(promises);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -201,7 +201,6 @@ export class AddonModWikiPrefetchHandler extends CoreCourseActivityPrefetchHandl
|
|||
promises.push(this.wikiProvider.getWiki(courseId, module.id, false, siteId).then((wiki) => {
|
||||
return this.courseHelper.getModuleCourseIdByInstance(wiki.id, 'wiki', siteId);
|
||||
}));
|
||||
promises.push(this.courseProvider.getModuleBasicInfo(module.id, siteId));
|
||||
|
||||
// Get related page files and fetch them.
|
||||
promises.push(this.getFiles(module, courseId, single, siteId).then((files) => {
|
||||
|
|
|
@ -101,8 +101,13 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
|
|||
}
|
||||
|
||||
const prefetchPromise = this.setDownloading(module.id, siteId).then(() => {
|
||||
// Package marked as downloading, call the download function.
|
||||
// Send all the params except downloadFn. This includes all params passed after siteId.
|
||||
// Package marked as downloading, get module info to be able to handle links.
|
||||
return Promise.all([
|
||||
this.courseProvider.getModuleBasicInfo(module.id, siteId),
|
||||
this.courseProvider.getModule(module.id, courseId, undefined, false, true, siteId),
|
||||
]);
|
||||
}).then(() => {
|
||||
// Call the download function, send all the params except downloadFn. This includes all params passed after siteId.
|
||||
return downloadFn.apply(downloadFn, [module, courseId, single, siteId].concat(args));
|
||||
}).then((extra: any) => {
|
||||
// Only accept string types.
|
||||
|
|
|
@ -61,8 +61,11 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
|
|||
return this.getOngoingDownload(module.id, siteId);
|
||||
}
|
||||
|
||||
// Load module contents (ignore cache so we always have the latest data).
|
||||
const prefetchPromise = this.loadContents(module, courseId, true).then(() => {
|
||||
// Get module info to be able to handle links.
|
||||
const prefetchPromise = this.courseProvider.getModuleBasicInfo(module.id, siteId).then(() => {
|
||||
// Load module contents (ignore cache so we always have the latest data).
|
||||
return this.loadContents(module, courseId, true);
|
||||
}).then(() => {
|
||||
// Get the intro files.
|
||||
return this.getIntroFiles(module, courseId);
|
||||
}).then((introFiles) => {
|
||||
|
|
Loading…
Reference in New Issue