From f70a95b0b9466e4149e226bf930abf754d33e0f7 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 28 May 2019 10:46:30 +0200 Subject: [PATCH] MOBILE-3039 grades: Fix repeated calls when prefetching grades --- .../grades/providers/course-option-handler.ts | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/core/grades/providers/course-option-handler.ts b/src/core/grades/providers/course-option-handler.ts index 7b253f723..ae04b5574 100644 --- a/src/core/grades/providers/course-option-handler.ts +++ b/src/core/grades/providers/course-option-handler.ts @@ -16,7 +16,6 @@ import { Injectable, Injector } from '@angular/core'; import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData } from '@core/course/providers/options-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreGradesProvider } from './grades'; -import { CoreGradesHelperProvider } from './helper'; import { CoreCoursesProvider } from '@core/courses/providers/courses'; import { CoreGradesCourseComponent } from '../components/course/course'; @@ -28,8 +27,7 @@ export class CoreGradesCourseOptionHandler implements CoreCourseOptionsHandler { name = 'CoreGrades'; priority = 400; - constructor(private gradesProvider: CoreGradesProvider, private coursesProvider: CoreCoursesProvider, - private gradesHelper: CoreGradesHelperProvider) {} + constructor(private gradesProvider: CoreGradesProvider, private coursesProvider: CoreCoursesProvider) {} /** * Should invalidate the data to determine if the handler is enabled for a certain course. @@ -100,20 +98,6 @@ export class CoreGradesCourseOptionHandler implements CoreCourseOptionsHandler { * @return {Promise} Promise resolved when done. */ prefetch(course: any): Promise { - return this.gradesProvider.getCourseGradesTable(course.id, undefined, undefined, true).then((table) => { - const promises = []; - - table = this.gradesHelper.formatGradesTable(table); - - if (table && table.rows) { - table.rows.forEach((row) => { - if (row.itemtype != 'category') { - promises.push(this.gradesHelper.getGradeItem(course.id, row.id, undefined, undefined, true)); - } - }); - } - - return Promise.all(promises); - }); + return this.gradesProvider.getCourseGradesTable(course.id, undefined, undefined, true); } }