MOBILE-3833 course: Improve getCoursesAdminAndNavOptions performance
parent
05ffa6f807
commit
147df9b58e
|
@ -20,6 +20,7 @@ import { CoreStatusWithWarningsWSResponse, CoreWarningsWSResponse, CoreWSExterna
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
import { CoreWSError } from '@classes/errors/wserror';
|
import { CoreWSError } from '@classes/errors/wserror';
|
||||||
import { CoreCourseAnyCourseDataWithExtraInfoAndOptions, CoreCourseWithImageAndColor } from './courses-helper';
|
import { CoreCourseAnyCourseDataWithExtraInfoAndOptions, CoreCourseWithImageAndColor } from './courses-helper';
|
||||||
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
|
||||||
const ROOT_CACHE_KEY = 'mmCourses:';
|
const ROOT_CACHE_KEY = 'mmCourses:';
|
||||||
|
|
||||||
|
@ -625,25 +626,13 @@ export class CoreCoursesProvider {
|
||||||
// Get the list of courseIds to use based on the param.
|
// Get the list of courseIds to use based on the param.
|
||||||
courseIds = await this.getCourseIdsForAdminAndNavOptions(courseIds, siteId);
|
courseIds = await this.getCourseIdsForAdminAndNavOptions(courseIds, siteId);
|
||||||
|
|
||||||
let navOptions: CoreCourseUserAdminOrNavOptionCourseIndexed;
|
|
||||||
let admOptions: CoreCourseUserAdminOrNavOptionCourseIndexed;
|
|
||||||
|
|
||||||
// Get user navigation and administration options.
|
// Get user navigation and administration options.
|
||||||
try {
|
const [navOptions, admOptions] = await Promise.all([
|
||||||
navOptions = await this.getUserNavigationOptions(courseIds, siteId);
|
CoreUtils.ignoreErrors(this.getUserNavigationOptions(courseIds, siteId), {}),
|
||||||
} catch {
|
CoreUtils.ignoreErrors(this.getUserAdministrationOptions(courseIds, siteId), {}),
|
||||||
// Couldn't get it, return empty options.
|
]);
|
||||||
navOptions = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
return { navOptions: navOptions, admOptions: admOptions };
|
||||||
admOptions = await this.getUserAdministrationOptions(courseIds, siteId);
|
|
||||||
} catch {
|
|
||||||
// Couldn't get it, return empty options.
|
|
||||||
admOptions = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
return ({ navOptions: navOptions, admOptions: admOptions });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue