MOBILE-3401 course: Prevent JS errors when clearing option handlers
parent
fd464d45ce
commit
536589c591
|
@ -243,11 +243,17 @@ export class CoreCourseOptionsDelegate extends CoreDelegate {
|
||||||
*/
|
*/
|
||||||
protected clearCoursesHandlers(courseId?: number): void {
|
protected clearCoursesHandlers(courseId?: number): void {
|
||||||
if (courseId) {
|
if (courseId) {
|
||||||
|
if (!this.loaded[courseId]) {
|
||||||
|
// Don't clear if not loaded, it's probably an ongoing load and it could cause JS errors.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.loaded[courseId] = false;
|
this.loaded[courseId] = false;
|
||||||
delete this.coursesHandlers[courseId];
|
delete this.coursesHandlers[courseId];
|
||||||
} else {
|
} else {
|
||||||
this.loaded = {};
|
for (const courseId in this.coursesHandlers) {
|
||||||
this.coursesHandlers = {};
|
this.clearCoursesHandlers(Number(courseId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +490,7 @@ export class CoreCourseOptionsDelegate extends CoreDelegate {
|
||||||
const promises = [],
|
const promises = [],
|
||||||
courseData = this.coursesHandlers[courseId];
|
courseData = this.coursesHandlers[courseId];
|
||||||
|
|
||||||
if (!courseData) {
|
if (!courseData || !courseData.enabledHandlers) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue