diff --git a/scripts/langindex.json b/scripts/langindex.json index 79aa4ffe2..f4b615cda 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -1188,6 +1188,7 @@ "core.courses.errorselfenrol": "local_moodlemobileapp", "core.courses.filtermycourses": "local_moodlemobileapp", "core.courses.frontpage": "admin", + "core.courses.hidecourse": "block_myoverview", "core.courses.mycourses": "moodle", "core.courses.mymoodle": "admin", "core.courses.nocourses": "my", @@ -1203,6 +1204,7 @@ "core.courses.searchcoursesadvice": "local_moodlemobileapp", "core.courses.selfenrolment": "local_moodlemobileapp", "core.courses.sendpaymentbutton": "enrol_paypal", + "core.courses.show": "block_myoverview", "core.courses.totalcoursesearchresults": "local_moodlemobileapp", "core.currentdevice": "local_moodlemobileapp", "core.datastoredoffline": "local_moodlemobileapp", diff --git a/src/addon/block/recentlyaccessedcourses/components/recentlyaccessedcourses/recentlyaccessedcourses.ts b/src/addon/block/recentlyaccessedcourses/components/recentlyaccessedcourses/recentlyaccessedcourses.ts index 9f1b3d64d..d81c2fc07 100644 --- a/src/addon/block/recentlyaccessedcourses/components/recentlyaccessedcourses/recentlyaccessedcourses.ts +++ b/src/addon/block/recentlyaccessedcourses/components/recentlyaccessedcourses/recentlyaccessedcourses.ts @@ -15,6 +15,7 @@ import { Component, OnInit, OnDestroy, Injector } from '@angular/core'; import { CoreEventsProvider } from '@providers/events'; import { CoreUtilsProvider } from '@providers/utils/utils'; +import { CoreSitesProvider } from '@providers/sites'; import { CoreCoursesProvider } from '@core/courses/providers/courses'; import { CoreCoursesHelperProvider } from '@core/courses/providers/helper'; import { CoreCourseHelperProvider } from '@core/course/providers/helper'; @@ -40,13 +41,15 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom protected prefetchIconsInitialized = false; protected isDestroyed; protected updateSiteObserver; + protected coursesObserver; protected courseIds = []; protected fetchContentDefaultError = 'Error getting recent courses data.'; constructor(injector: Injector, private coursesProvider: CoreCoursesProvider, private courseCompletionProvider: AddonCourseCompletionProvider, private eventsProvider: CoreEventsProvider, private courseHelper: CoreCourseHelperProvider, private utils: CoreUtilsProvider, - private courseOptionsDelegate: CoreCourseOptionsDelegate, private coursesHelper: CoreCoursesHelperProvider) { + private courseOptionsDelegate: CoreCourseOptionsDelegate, private coursesHelper: CoreCoursesHelperProvider, + private sitesProvider: CoreSitesProvider) { super(injector, 'AddonBlockRecentlyAccessedCoursesComponent'); } @@ -67,7 +70,11 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom // Download all courses is enabled now, initialize it. this.initPrefetchCoursesIcons(); } - }); + }, this.sitesProvider.getCurrentSiteId()); + + this.coursesObserver = this.eventsProvider.on(CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, () => { + this.refreshContent(); + }, this.sitesProvider.getCurrentSiteId()); super.ngOnInit(); } @@ -147,6 +154,7 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom */ ngOnDestroy(): void { this.isDestroyed = true; + this.coursesObserver && this.coursesObserver.off(); this.updateSiteObserver && this.updateSiteObserver.off(); } } diff --git a/src/core/courses/components/course-progress/course-progress.ts b/src/core/courses/components/course-progress/course-progress.ts index 6e4ac089d..09c9167c9 100644 --- a/src/core/courses/components/course-progress/course-progress.ts +++ b/src/core/courses/components/course-progress/course-progress.ts @@ -68,6 +68,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy { this.initPrefetchCourse(); } + // This field is only available from 3.6 onwards. this.courseOptionMenuEnabled = typeof this.course.isfavourite != 'undefined'; // Refresh the enabled flag if site is updated. @@ -203,7 +204,8 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy { protected setCourseHidden(hide: boolean): void { this.showSpinner = true; - this.userProvider.updateUserPreference('block_myoverview_hidden_course_' + this.course.id, hide ? 1 : false).then(() => { + // We should use null to unset the preference. + this.userProvider.updateUserPreference('block_myoverview_hidden_course_' + this.course.id, hide ? 1 : null).then(() => { this.course.hidden = hide; this.eventsProvider.trigger( CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, {course: this.course}, this.sitesProvider.getCurrentSiteId()); diff --git a/src/core/courses/pages/dashboard/dashboard.ts b/src/core/courses/pages/dashboard/dashboard.ts index 51a52a9e7..591b5fec5 100644 --- a/src/core/courses/pages/dashboard/dashboard.ts +++ b/src/core/courses/pages/dashboard/dashboard.ts @@ -69,7 +69,7 @@ export class CoreCoursesDashboardPage implements OnDestroy { this.updateSiteObserver = this.eventsProvider.on(CoreEventsProvider.SITE_UPDATED, () => { this.searchEnabled = !this.coursesProvider.isSearchCoursesDisabledInSite(); this.loadSiteName(); - }); + }, this.sitesProvider.getCurrentSiteId()); const promises = [];