Merge pull request #1670 from dpalou/MOBILE-2697

MOBILE-2697 course: Fix course options order
main
Juan Leyva 2018-12-17 14:24:32 +01:00 committed by GitHub
commit 783b7fe3a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -24,7 +24,7 @@ import { AddonCompetencyProvider } from '../providers/competency';
@Injectable()
export class AddonCompetencyCourseOptionHandler implements CoreCourseOptionsHandler {
name = 'AddonCompetency';
priority = 700;
priority = 300;
constructor(private competencyProvider: AddonCompetencyProvider) {}

View File

@ -261,8 +261,9 @@ export class CoreCourseOptionsDelegate extends CoreDelegate {
course.id = parseInt(course.id, 10);
const accessData = {
type: isGuest ? CoreCourseProvider.ACCESS_GUEST : CoreCourseProvider.ACCESS_DEFAULT
};
type: isGuest ? CoreCourseProvider.ACCESS_GUEST : CoreCourseProvider.ACCESS_DEFAULT
},
handlersToDisplay: CoreCourseOptionsHandlerToDisplay[] = [];
if (navOptions) {
course.navOptions = navOptions;
@ -275,8 +276,7 @@ export class CoreCourseOptionsDelegate extends CoreDelegate {
// Call getHandlersForAccess to make sure the handlers have been loaded.
return this.getHandlersForAccess(course.id, refresh, accessData, course.navOptions, course.admOptions);
}).then(() => {
const handlersToDisplay: CoreCourseOptionsHandlerToDisplay[] = [],
promises = [];
const promises = [];
this.coursesHandlers[course.id].enabledHandlers.forEach((handler) => {
promises.push(Promise.resolve(handler.getDisplayData(injector, course)).then((data) => {
@ -291,6 +291,9 @@ export class CoreCourseOptionsDelegate extends CoreDelegate {
}));
});
return Promise.all(promises);
}).then(() => {
// Sort them by priority.
handlersToDisplay.sort((a, b) => {
return b.priority - a.priority;