MOBILE-3039 grades: Fix repeated calls when prefetching grades
parent
4a758cba74
commit
f70a95b0b9
|
@ -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<any>} Promise resolved when done.
|
||||
*/
|
||||
prefetch(course: any): Promise<any> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue