MOBILE-2688 courses: Invalidate course list when updated
parent
ed9dd1bba0
commit
0c0c01b8ce
|
@ -1188,6 +1188,7 @@
|
||||||
"core.courses.errorselfenrol": "local_moodlemobileapp",
|
"core.courses.errorselfenrol": "local_moodlemobileapp",
|
||||||
"core.courses.filtermycourses": "local_moodlemobileapp",
|
"core.courses.filtermycourses": "local_moodlemobileapp",
|
||||||
"core.courses.frontpage": "admin",
|
"core.courses.frontpage": "admin",
|
||||||
|
"core.courses.hidecourse": "block_myoverview",
|
||||||
"core.courses.mycourses": "moodle",
|
"core.courses.mycourses": "moodle",
|
||||||
"core.courses.mymoodle": "admin",
|
"core.courses.mymoodle": "admin",
|
||||||
"core.courses.nocourses": "my",
|
"core.courses.nocourses": "my",
|
||||||
|
@ -1203,6 +1204,7 @@
|
||||||
"core.courses.searchcoursesadvice": "local_moodlemobileapp",
|
"core.courses.searchcoursesadvice": "local_moodlemobileapp",
|
||||||
"core.courses.selfenrolment": "local_moodlemobileapp",
|
"core.courses.selfenrolment": "local_moodlemobileapp",
|
||||||
"core.courses.sendpaymentbutton": "enrol_paypal",
|
"core.courses.sendpaymentbutton": "enrol_paypal",
|
||||||
|
"core.courses.show": "block_myoverview",
|
||||||
"core.courses.totalcoursesearchresults": "local_moodlemobileapp",
|
"core.courses.totalcoursesearchresults": "local_moodlemobileapp",
|
||||||
"core.currentdevice": "local_moodlemobileapp",
|
"core.currentdevice": "local_moodlemobileapp",
|
||||||
"core.datastoredoffline": "local_moodlemobileapp",
|
"core.datastoredoffline": "local_moodlemobileapp",
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import { Component, OnInit, OnDestroy, Injector } from '@angular/core';
|
import { Component, OnInit, OnDestroy, Injector } from '@angular/core';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
import { CoreCoursesProvider } from '@core/courses/providers/courses';
|
import { CoreCoursesProvider } from '@core/courses/providers/courses';
|
||||||
import { CoreCoursesHelperProvider } from '@core/courses/providers/helper';
|
import { CoreCoursesHelperProvider } from '@core/courses/providers/helper';
|
||||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||||
|
@ -40,13 +41,15 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
|
||||||
protected prefetchIconsInitialized = false;
|
protected prefetchIconsInitialized = false;
|
||||||
protected isDestroyed;
|
protected isDestroyed;
|
||||||
protected updateSiteObserver;
|
protected updateSiteObserver;
|
||||||
|
protected coursesObserver;
|
||||||
protected courseIds = [];
|
protected courseIds = [];
|
||||||
protected fetchContentDefaultError = 'Error getting recent courses data.';
|
protected fetchContentDefaultError = 'Error getting recent courses data.';
|
||||||
|
|
||||||
constructor(injector: Injector, private coursesProvider: CoreCoursesProvider,
|
constructor(injector: Injector, private coursesProvider: CoreCoursesProvider,
|
||||||
private courseCompletionProvider: AddonCourseCompletionProvider, private eventsProvider: CoreEventsProvider,
|
private courseCompletionProvider: AddonCourseCompletionProvider, private eventsProvider: CoreEventsProvider,
|
||||||
private courseHelper: CoreCourseHelperProvider, private utils: CoreUtilsProvider,
|
private courseHelper: CoreCourseHelperProvider, private utils: CoreUtilsProvider,
|
||||||
private courseOptionsDelegate: CoreCourseOptionsDelegate, private coursesHelper: CoreCoursesHelperProvider) {
|
private courseOptionsDelegate: CoreCourseOptionsDelegate, private coursesHelper: CoreCoursesHelperProvider,
|
||||||
|
private sitesProvider: CoreSitesProvider) {
|
||||||
|
|
||||||
super(injector, 'AddonBlockRecentlyAccessedCoursesComponent');
|
super(injector, 'AddonBlockRecentlyAccessedCoursesComponent');
|
||||||
}
|
}
|
||||||
|
@ -67,7 +70,11 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
|
||||||
// Download all courses is enabled now, initialize it.
|
// Download all courses is enabled now, initialize it.
|
||||||
this.initPrefetchCoursesIcons();
|
this.initPrefetchCoursesIcons();
|
||||||
}
|
}
|
||||||
});
|
}, this.sitesProvider.getCurrentSiteId());
|
||||||
|
|
||||||
|
this.coursesObserver = this.eventsProvider.on(CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, () => {
|
||||||
|
this.refreshContent();
|
||||||
|
}, this.sitesProvider.getCurrentSiteId());
|
||||||
|
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
}
|
}
|
||||||
|
@ -147,6 +154,7 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
|
||||||
*/
|
*/
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.isDestroyed = true;
|
this.isDestroyed = true;
|
||||||
|
this.coursesObserver && this.coursesObserver.off();
|
||||||
this.updateSiteObserver && this.updateSiteObserver.off();
|
this.updateSiteObserver && this.updateSiteObserver.off();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
|
||||||
this.initPrefetchCourse();
|
this.initPrefetchCourse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This field is only available from 3.6 onwards.
|
||||||
this.courseOptionMenuEnabled = typeof this.course.isfavourite != 'undefined';
|
this.courseOptionMenuEnabled = typeof this.course.isfavourite != 'undefined';
|
||||||
|
|
||||||
// Refresh the enabled flag if site is updated.
|
// Refresh the enabled flag if site is updated.
|
||||||
|
@ -203,7 +204,8 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
|
||||||
protected setCourseHidden(hide: boolean): void {
|
protected setCourseHidden(hide: boolean): void {
|
||||||
this.showSpinner = true;
|
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.course.hidden = hide;
|
||||||
this.eventsProvider.trigger(
|
this.eventsProvider.trigger(
|
||||||
CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, {course: this.course}, this.sitesProvider.getCurrentSiteId());
|
CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, {course: this.course}, this.sitesProvider.getCurrentSiteId());
|
||||||
|
|
|
@ -69,7 +69,7 @@ export class CoreCoursesDashboardPage implements OnDestroy {
|
||||||
this.updateSiteObserver = this.eventsProvider.on(CoreEventsProvider.SITE_UPDATED, () => {
|
this.updateSiteObserver = this.eventsProvider.on(CoreEventsProvider.SITE_UPDATED, () => {
|
||||||
this.searchEnabled = !this.coursesProvider.isSearchCoursesDisabledInSite();
|
this.searchEnabled = !this.coursesProvider.isSearchCoursesDisabledInSite();
|
||||||
this.loadSiteName();
|
this.loadSiteName();
|
||||||
});
|
}, this.sitesProvider.getCurrentSiteId());
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue