From 79d3f02f72639b407bd874ba25a004955475eb96 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 7 Jun 2019 11:13:24 +0200 Subject: [PATCH] MOBILE-3039 workshop: Prefetch files from submissions to assess --- .../mod/workshop/providers/prefetch-handler.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/addon/mod/workshop/providers/prefetch-handler.ts b/src/addon/mod/workshop/providers/prefetch-handler.ts index 9ec409fa3..49cc62055 100644 --- a/src/addon/mod/workshop/providers/prefetch-handler.ts +++ b/src/addon/mod/workshop/providers/prefetch-handler.ts @@ -319,17 +319,25 @@ export class AddonModWorkshopPrefetchHandler extends CoreCourseActivityPrefetchH reportPromise = reportPromise.finally(() => { return this.workshopHelper.getReviewerAssessments(workshop.id, currentUserId, undefined, undefined, siteId).then((revAssessments) => { - let p = Promise.resolve(); + + const promises = []; + let files = []; // Files in each submission. + revAssessments.forEach((assessment) => { if (assessment.submission.authorid == currentUserId) { - p = this.workshopProvider.getAssessment(workshop.id, assessment.id); + promises.push(this.workshopProvider.getAssessment(workshop.id, assessment.id)); } userIds.push(assessment.reviewerid); userIds.push(assessment.gradinggradeoverby); assessments[assessment.id] = assessment; + + files = files.concat(assessment.submission.attachmentfiles || []) + .concat(assessment.submission.contentfiles || []); }); - return p; + promises.push(this.filepoolProvider.addFilesToQueue(siteId, files, this.component, module.id)); + + return Promise.all(promises); }); }); }