diff --git a/src/addon/mod/assign/components/index/index.ts b/src/addon/mod/assign/components/index/index.ts index 0361570eb..482a4d824 100644 --- a/src/addon/mod/assign/components/index/index.ts +++ b/src/addon/mod/assign/components/index/index.ts @@ -219,8 +219,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo } }); }); - }).then(() => { - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/book/components/index/index.ts b/src/addon/mod/book/components/index/index.ts index 267c0343a..d419bbed0 100644 --- a/src/addon/mod/book/components/index/index.ts +++ b/src/addon/mod/book/components/index/index.ts @@ -163,12 +163,11 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp // We could load the main file but the download failed. Show error message. this.domUtils.showErrorModal('core.errordownloadingsomefiles', true); } - - // All data obtained, now fill the context menu. - this.fillContextMenu(refresh); }).catch(() => { // Ignore errors, they're handled inside the loadChapter function. }); + }).finally(() => { + this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/chat/components/index/index.ts b/src/addon/mod/chat/components/index/index.ts index 4945a5ebe..73653b151 100644 --- a/src/addon/mod/chat/components/index/index.ts +++ b/src/addon/mod/chat/components/index/index.ts @@ -82,12 +82,11 @@ export class AddonModChatIndexComponent extends CoreCourseModuleMainActivityComp this.dataRetrieved.emit(chat); - // All data obtained, now fill the context menu. - this.fillContextMenu(refresh); - return this.chatProvider.areSessionsAvailable().then((available) => { this.sessionsAvailable = available; }); + }).finally(() => { + this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/choice/components/index/index.ts b/src/addon/mod/choice/components/index/index.ts index 6e3b5799e..df0979741 100644 --- a/src/addon/mod/choice/components/index/index.ts +++ b/src/addon/mod/choice/components/index/index.ts @@ -156,8 +156,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo return this.fetchOptions(hasOffline).then(() => { return this.fetchResults(); }); - }).then(() => { - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/data/components/index/index.ts b/src/addon/mod/data/components/index/index.ts index ab8998c2d..3e5688421 100644 --- a/src/addon/mod/data/components/index/index.ts +++ b/src/addon/mod/data/components/index/index.ts @@ -247,12 +247,10 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp return this.fetchEntriesData(); }); - }).then(() => { - // All data obtained, now fill the context menu. - this.fillContextMenu(refresh); }).finally(() => { this.canAdd = canAdd; this.canSearch = canSearch; + this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/folder/components/index/index.ts b/src/addon/mod/folder/components/index/index.ts index dc9b246dd..55a89fb34 100644 --- a/src/addon/mod/folder/components/index/index.ts +++ b/src/addon/mod/folder/components/index/index.ts @@ -126,8 +126,7 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo return promise.then((folder) => { this.showModuleData(folder); - - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/forum/components/index/index.ts b/src/addon/mod/forum/components/index/index.ts index 9d3f84803..78474fbd0 100644 --- a/src/addon/mod/forum/components/index/index.ts +++ b/src/addon/mod/forum/components/index/index.ts @@ -244,8 +244,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom this.domUtils.showErrorModalDefault(message, 'addon.mod_forum.errorgetforum', true); this.loadMoreError = true; // Set to prevent infinite calls with infinite-loading. - }).then(() => { - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/glossary/components/index/index.ts b/src/addon/mod/glossary/components/index/index.ts index 7572f19b6..27d8d8b34 100644 --- a/src/addon/mod/glossary/components/index/index.ts +++ b/src/addon/mod/glossary/components/index/index.ts @@ -158,8 +158,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity })); return Promise.all(promises); - }).then(() => { - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/imscp/components/index/index.ts b/src/addon/mod/imscp/components/index/index.ts index 6940db0d8..7ff8a0749 100644 --- a/src/addon/mod/imscp/components/index/index.ts +++ b/src/addon/mod/imscp/components/index/index.ts @@ -112,7 +112,7 @@ export class AddonModImscpIndexComponent extends CoreCourseModuleMainResourceCom this.domUtils.showErrorModal('core.errordownloadingsomefiles', true); } - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/lesson/components/index/index.ts b/src/addon/mod/lesson/components/index/index.ts index d236da208..1984da107 100644 --- a/src/addon/mod/lesson/components/index/index.ts +++ b/src/addon/mod/lesson/components/index/index.ts @@ -211,6 +211,8 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo this.lessonReady(refresh); } }); + }).finally(() => { + this.fillContextMenu(refresh); }); } @@ -336,9 +338,6 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo // Store the password in DB. this.lessonProvider.storePassword(this.lesson.id, this.password); } - - // All data obtained, now fill the context menu. - this.fillContextMenu(refresh); } /** diff --git a/src/addon/mod/lti/components/index/index.ts b/src/addon/mod/lti/components/index/index.ts index f454dec08..2d5e3fd4e 100644 --- a/src/addon/mod/lti/components/index/index.ts +++ b/src/addon/mod/lti/components/index/index.ts @@ -67,8 +67,7 @@ export class AddonModLtiIndexComponent extends CoreCourseModuleMainActivityCompo this.lti = ltiData; this.description = this.lti.intro; this.dataRetrieved.emit(this.lti); - }).then(() => { - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/page/components/index/index.ts b/src/addon/mod/page/components/index/index.ts index a4297216c..f8b1dd6ff 100644 --- a/src/addon/mod/page/components/index/index.ts +++ b/src/addon/mod/page/components/index/index.ts @@ -127,8 +127,6 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp // Get the page HTML. promises.push(this.pageHelper.getPageHtml(this.module.contents, this.module.id).then((content) => { - // All data obtained, now fill the context menu. - this.fillContextMenu(refresh); this.contents = content; @@ -139,6 +137,8 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp })); return Promise.all(promises); + }).finally(() => { + this.fillContextMenu(refresh); }); } } diff --git a/src/addon/mod/quiz/components/index/index.ts b/src/addon/mod/quiz/components/index/index.ts index 5aae59e52..52dd2930b 100644 --- a/src/addon/mod/quiz/components/index/index.ts +++ b/src/addon/mod/quiz/components/index/index.ts @@ -224,11 +224,10 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp }); }).then(() => { - // All data obtained, now fill the context menu. - this.fillContextMenu(refresh); - // Quiz is ready to be shown, move it to the variable that is displayed. this.quiz = this.quizData; + }).finally(() => { + this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/resource/components/index/index.ts b/src/addon/mod/resource/components/index/index.ts index fd52daa25..1717d360a 100644 --- a/src/addon/mod/resource/components/index/index.ts +++ b/src/addon/mod/resource/components/index/index.ts @@ -135,8 +135,7 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource } else { this.mode = 'external'; } - }).then(() => { - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/scorm/components/index/index.ts b/src/addon/mod/scorm/components/index/index.ts index b93fe28d9..530ac4e47 100644 --- a/src/addon/mod/scorm/components/index/index.ts +++ b/src/addon/mod/scorm/components/index/index.ts @@ -254,8 +254,7 @@ export class AddonModScormIndexComponent extends CoreCourseModuleMainActivityCom } }); }); - }).then(() => { - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/survey/components/index/index.ts b/src/addon/mod/survey/components/index/index.ts index e1715f02a..b51dfab60 100644 --- a/src/addon/mod/survey/components/index/index.ts +++ b/src/addon/mod/survey/components/index/index.ts @@ -126,8 +126,7 @@ export class AddonModSurveyIndexComponent extends CoreCourseModuleMainActivityCo if (!this.survey.surveydone && !this.hasOffline) { return this.fetchQuestions(); } - }).then(() => { - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }); } diff --git a/src/addon/mod/wiki/components/index/index.ts b/src/addon/mod/wiki/components/index/index.ts index 7296709d2..ff7d5d00d 100644 --- a/src/addon/mod/wiki/components/index/index.ts +++ b/src/addon/mod/wiki/components/index/index.ts @@ -299,8 +299,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp return this.fetchWikiPage(); }); }); - }).then(() => { - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }).catch((error) => { if (this.pageWarning) { diff --git a/src/addon/mod/workshop/components/index/index.ts b/src/addon/mod/workshop/components/index/index.ts index b4f88d644..f20824ca7 100644 --- a/src/addon/mod/workshop/components/index/index.ts +++ b/src/addon/mod/workshop/components/index/index.ts @@ -231,8 +231,7 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity }); }).then(() => { return this.setPhaseInfo(); - }).then(() => { - // All data obtained, now fill the context menu. + }).finally(() => { this.fillContextMenu(refresh); }); }