From aef7a64db7bb9958c1237566bf8a9eac96bc1211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 14 Oct 2021 13:07:29 +0200 Subject: [PATCH] MOBILE-3686 courses: Do not check my courses disabled on list --- .../courses/pages/categories/categories.html | 2 +- .../courses/pages/categories/categories.ts | 3 --- .../features/courses/pages/dashboard/dashboard.ts | 4 ++-- src/core/features/courses/pages/list/list.html | 2 +- src/core/features/courses/pages/list/list.ts | 14 ++++---------- src/core/features/courses/services/dashboard.ts | 2 +- src/core/features/sitehome/pages/index/index.ts | 4 ++-- src/core/features/sitehome/services/sitehome.ts | 14 +++----------- 8 files changed, 14 insertions(+), 31 deletions(-) diff --git a/src/core/features/courses/pages/categories/categories.html b/src/core/features/courses/pages/categories/categories.html index eec8dd4a5..33fb19de2 100644 --- a/src/core/features/courses/pages/categories/categories.html +++ b/src/core/features/courses/pages/categories/categories.html @@ -12,7 +12,7 @@ - diff --git a/src/core/features/courses/pages/categories/categories.ts b/src/core/features/courses/pages/categories/categories.ts index c5969bcae..34dd3c7a0 100644 --- a/src/core/features/courses/pages/categories/categories.ts +++ b/src/core/features/courses/pages/categories/categories.ts @@ -36,7 +36,6 @@ export class CoreCoursesCategoriesPage implements OnInit, OnDestroy { categories: CoreCategoryData[] = []; courses: CoreCourseListItem[] = []; categoriesLoaded = false; - myCoursesEnabled = true; showOnlyEnrolled = false; @@ -72,7 +71,6 @@ export class CoreCoursesCategoriesPage implements OnInit, OnDestroy { this.siteUpdatedObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => { this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); - this.myCoursesEnabled = !CoreCourses.isMyCoursesDisabledInSite(); this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && this.downloadEnabled; }, this.currentSiteId); @@ -91,7 +89,6 @@ export class CoreCoursesCategoriesPage implements OnInit, OnDestroy { this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); - this.myCoursesEnabled = !CoreCourses.isMyCoursesDisabledInSite(); this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && CoreCourses.getCourseDownloadOptionsEnabled(); diff --git a/src/core/features/courses/pages/dashboard/dashboard.ts b/src/core/features/courses/pages/dashboard/dashboard.ts index 28180ea4e..712f893e5 100644 --- a/src/core/features/courses/pages/dashboard/dashboard.ts +++ b/src/core/features/courses/pages/dashboard/dashboard.ts @@ -148,11 +148,11 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy { } /** - * Convenience function to switch download enabled. + * Switch download enabled. * * @param enable If enable or disable. */ - protected switchDownload(enable: boolean): void { + switchDownload(enable: boolean): void { this.downloadEnabled = CoreCourses.setCourseDownloadOptionsEnabled((this.downloadCourseEnabled || this.downloadCoursesEnabled) && enable); } diff --git a/src/core/features/courses/pages/list/list.html b/src/core/features/courses/pages/list/list.html index 838ce9ae1..90593d24f 100644 --- a/src/core/features/courses/pages/list/list.html +++ b/src/core/features/courses/pages/list/list.html @@ -11,7 +11,7 @@ - diff --git a/src/core/features/courses/pages/list/list.ts b/src/core/features/courses/pages/list/list.ts index a510d5b5b..64edc1eee 100644 --- a/src/core/features/courses/pages/list/list.ts +++ b/src/core/features/courses/pages/list/list.ts @@ -35,7 +35,6 @@ export class CoreCoursesListPage implements OnInit, OnDestroy { downloadAllCoursesEnabled = false; searchEnabled = false; - myCoursesEnabled = true; searchMode = false; searchCanLoadMore = false; searchLoadMoreError = false; @@ -84,7 +83,6 @@ export class CoreCoursesListPage implements OnInit, OnDestroy { this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite(); this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); - this.myCoursesEnabled = !CoreCourses.isMyCoursesDisabledInSite(); this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && this.downloadEnabled; if (!this.searchEnabled) { @@ -111,12 +109,6 @@ export class CoreCoursesListPage implements OnInit, OnDestroy { this.mode = CoreNavigator.getRouteParam('mode') || this.mode; - this.myCoursesEnabled = !CoreCourses.isMyCoursesDisabledInSite(); - if (this.mode == 'my' && !this.myCoursesEnabled) { - this.mode = 'all'; - this.showOnlyEnrolled = false; - } - if (this.mode == 'search') { this.searchMode = true; } @@ -140,8 +132,10 @@ export class CoreCoursesListPage implements OnInit, OnDestroy { */ protected async fetchCourses(): Promise { try { - if (this.searchMode && this.searchText) { - await this.search(this.searchText); + if (this.searchMode) { + if (this.searchText) { + await this.search(this.searchText); + } } else if (this.showOnlyEnrolled) { await this.loadMyCourses(); } else { diff --git a/src/core/features/courses/services/dashboard.ts b/src/core/features/courses/services/dashboard.ts index 717a43206..d592f2e2d 100644 --- a/src/core/features/courses/services/dashboard.ts +++ b/src/core/features/courses/services/dashboard.ts @@ -107,7 +107,7 @@ export class CoreCoursesDashboardProvider { } /** - * Check if Site Home is disabled in a certain site. + * Check if Dashboard is disabled in a certain site. * * @param site Site. If not defined, use current site. * @return Whether it's disabled. diff --git a/src/core/features/sitehome/pages/index/index.ts b/src/core/features/sitehome/pages/index/index.ts index 4f2aff5c5..81ecc1c03 100644 --- a/src/core/features/sitehome/pages/index/index.ts +++ b/src/core/features/sitehome/pages/index/index.ts @@ -194,11 +194,11 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy { } /** - * Convenience function to switch download enabled. + * Switch download enabled. * * @param enable If enable or disable. */ - protected switchDownload(enable: boolean): void { + switchDownload(enable: boolean): void { this.downloadEnabled = CoreCourses.setCourseDownloadOptionsEnabled(enable); } diff --git a/src/core/features/sitehome/services/sitehome.ts b/src/core/features/sitehome/services/sitehome.ts index 3de9e2ef9..596d144ef 100644 --- a/src/core/features/sitehome/services/sitehome.ts +++ b/src/core/features/sitehome/services/sitehome.ts @@ -169,20 +169,12 @@ export class CoreSiteHomeProvider { // Get number of news items to show. add = !!CoreSites.getCurrentSite()?.getStoredConfig('newsitems'); break; - case FrontPageItemNames['LIST_OF_CATEGORIES']: case FrontPageItemNames['COMBO_LIST']: + itemNumber = FrontPageItemNames['LIST_OF_CATEGORIES']; // Do not break here. + case FrontPageItemNames['LIST_OF_CATEGORIES']: case FrontPageItemNames['LIST_OF_COURSE']: - add = true; - if (itemNumber == FrontPageItemNames['COMBO_LIST']) { - itemNumber = FrontPageItemNames['LIST_OF_CATEGORIES']; - } - break; case FrontPageItemNames['ENROLLED_COURSES']: - if (!CoreCourses.isMyCoursesDisabledInSite()) { - const courses = await CoreCourses.getUserCourses(); - - add = courses.length > 0; - } + add = true; break; case FrontPageItemNames['COURSE_SEARCH_BOX']: add = !CoreCourses.isSearchCoursesDisabledInSite();