File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
www/core/components/courses/services Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -176,18 +176,14 @@ angular.module('mm.core.courses')
176176 * @protected
177177 */
178178 self . updateNavHandlersForCourse = function ( courseId ) {
179- var promises = [ ] ;
180-
181- $mmUtil . emptyArray ( coursesHandlers [ courseId ] ) ;
179+ var promises = [ ] ,
180+ enabledForCourse = [ ] ;
182181
183182 angular . forEach ( enabledNavHandlers , function ( handler ) {
184183 // Checks if the handler is enabled for the user.
185184 var promise = $q . when ( handler . instance . isEnabledForCourse ( courseId ) ) . then ( function ( enabled ) {
186185 if ( enabled ) {
187- coursesHandlers [ courseId ] . push ( {
188- controller : handler . instance . getController ( courseId ) ,
189- priority : handler . priority
190- } ) ;
186+ enabledForCourse . push ( handler ) ;
191187 } else {
192188 return $q . reject ( ) ;
193189 }
@@ -202,6 +198,15 @@ angular.module('mm.core.courses')
202198 } ) . catch ( function ( ) {
203199 // Never fails.
204200 return true ;
201+ } ) . finally ( function ( ) {
202+ // Update the coursesHandlers array with the new enabled addons.
203+ $mmUtil . emptyArray ( coursesHandlers [ courseId ] ) ;
204+ angular . forEach ( enabledForCourse , function ( handler ) {
205+ coursesHandlers [ courseId ] . push ( {
206+ controller : handler . instance . getController ( courseId ) ,
207+ priority : handler . priority
208+ } ) ;
209+ } ) ;
205210 } ) ;
206211 } ;
207212
You can’t perform that action at this time.
0 commit comments