From 06c0a266b79eeefd68c6bc6ea4c74238d0ec58e8 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 5 Sep 2019 09:23:44 +0200 Subject: [PATCH] MOBILE-3132 mod: Fill context menu even if there's an error --- src/addon/mod/assign/components/index/index.ts | 3 +-- src/addon/mod/book/components/index/index.ts | 5 ++--- src/addon/mod/chat/components/index/index.ts | 5 ++--- src/addon/mod/choice/components/index/index.ts | 3 +-- src/addon/mod/data/components/index/index.ts | 4 +--- src/addon/mod/folder/components/index/index.ts | 3 +-- src/addon/mod/forum/components/index/index.ts | 3 +-- src/addon/mod/glossary/components/index/index.ts | 3 +-- src/addon/mod/imscp/components/index/index.ts | 2 +- src/addon/mod/lesson/components/index/index.ts | 5 ++--- src/addon/mod/lti/components/index/index.ts | 3 +-- src/addon/mod/page/components/index/index.ts | 4 ++-- src/addon/mod/quiz/components/index/index.ts | 5 ++--- src/addon/mod/resource/components/index/index.ts | 3 +-- src/addon/mod/scorm/components/index/index.ts | 3 +-- src/addon/mod/survey/components/index/index.ts | 3 +-- src/addon/mod/wiki/components/index/index.ts | 3 +-- src/addon/mod/workshop/components/index/index.ts | 3 +-- 18 files changed, 23 insertions(+), 40 deletions(-) diff --git a/src/addon/mod/assign/components/index/index.ts b/src/addon/mod/assign/components/index/index.ts index 26d57888e..a576d75a5 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 569060aa3..56ed8c12e 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 585c6f4e8..9b8f1f4ac 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 b543e4013..514dbae8a 100644 --- a/src/addon/mod/choice/components/index/index.ts +++ b/src/addon/mod/choice/components/index/index.ts @@ -154,8 +154,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 bc3463842..2bc9aab6f 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 d8c296b00..11e08acde 100644 --- a/src/addon/mod/folder/components/index/index.ts +++ b/src/addon/mod/folder/components/index/index.ts @@ -129,8 +129,7 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo } 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 b3a4209b6..78e4d4d84 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 ed3d807e9..74296d771 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 3b793da19..1c7dce1b2 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 b179e7993..65411e0f2 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 f61c1e50f..600ca24b5 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.description; 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 254bc0f38..bec1d8d23 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 cabdb8406..c5b8ae1f7 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 ab8ccffac..52ec1bcfc 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 6672548b7..ea51cd2a4 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 8b6cfbb65..23b279d47 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 cb91ef072..79b2b9089 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 6e96123a2..7369f8a5e 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); }); }