diff --git a/scripts/langindex.json b/scripts/langindex.json
index db1744aee..df6d554e3 100644
--- a/scripts/langindex.json
+++ b/scripts/langindex.json
@@ -1556,6 +1556,7 @@
"core.courses.password": "local_moodlemobileapp",
"core.courses.paymentrequired": "moodle",
"core.courses.paypalaccepted": "enrol_paypal",
+ "core.courses.refreshcourses": "local_moodlemobileapp",
"core.courses.reload": "moodle",
"core.courses.removefromfavourites": "block_myoverview",
"core.courses.search": "moodle",
diff --git a/src/addons/block/myoverview/components/myoverview/addon-block-myoverview.html b/src/addons/block/myoverview/components/myoverview/addon-block-myoverview.html
index 121ae723b..6c3d9ffa6 100644
--- a/src/addons/block/myoverview/components/myoverview/addon-block-myoverview.html
+++ b/src/addons/block/myoverview/components/myoverview/addon-block-myoverview.html
@@ -6,7 +6,7 @@
1" class="core-button-spinner">
+ [attr.aria-label]="prefetchCoursesData.statusTranslatable | translate">
diff --git a/src/addons/block/myoverview/components/myoverview/myoverview.ts b/src/addons/block/myoverview/components/myoverview/myoverview.ts
index a3970be95..d99e22201 100644
--- a/src/addons/block/myoverview/components/myoverview/myoverview.ts
+++ b/src/addons/block/myoverview/components/myoverview/myoverview.ts
@@ -415,7 +415,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
*
* @return Promise resolved when done.
*/
- protected async initPrefetchCoursesIcons(): Promise {
+ async initPrefetchCoursesIcons(): Promise {
if (this.prefetchIconsInitialized || !this.downloadEnabled) {
// Already initialized.
return;
diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts
index b87b0ab95..768470957 100644
--- a/src/core/features/course/services/course-helper.ts
+++ b/src/core/features/course/services/course-helper.ts
@@ -429,7 +429,7 @@ export class CoreCourseHelperProvider {
const siteId = CoreSites.getCurrentSiteId();
// Confirm the download without checking size because it could take a while.
- await CoreDomUtils.showConfirm(Translate.instant('core.areyousure'));
+ await CoreDomUtils.showConfirm(Translate.instant('core.areyousure'), Translate.instant('core.courses.downloadcourses'));
const total = courses.length;
let count = 0;
@@ -1209,7 +1209,7 @@ export class CoreCourseHelperProvider {
const status = await this.determineCoursesStatus(courses);
- prefetch = this.getCoursePrefetchStatusInfo(status);
+ prefetch = this.getCoursesPrefetchStatusInfo(status);
if (prefetch.loading) {
// It seems all courses are being downloaded, show a download button instead.
@@ -1381,6 +1381,33 @@ export class CoreCourseHelperProvider {
return prefetchStatus;
}
+ /**
+ * Get a courses status icon and the langkey to use as a title from status.
+ *
+ * @param status Courses status.
+ * @return Prefetch status info.
+ */
+ getCoursesPrefetchStatusInfo(status: string): CorePrefetchStatusInfo {
+ const prefetchStatus: CorePrefetchStatusInfo = {
+ status: status,
+ icon: this.getPrefetchStatusIcon(status, false),
+ statusTranslatable: '',
+ loading: false,
+ };
+
+ if (status == CoreConstants.DOWNLOADED) {
+ // Always show refresh icon, we cannot know if there's anything new in course options.
+ prefetchStatus.statusTranslatable = 'core.courses.refreshcourses';
+ } else if (status == CoreConstants.DOWNLOADING) {
+ prefetchStatus.statusTranslatable = 'core.downloading';
+ prefetchStatus.loading = true;
+ } else {
+ prefetchStatus.statusTranslatable = 'core.courses.downloadcourses';
+ }
+
+ return prefetchStatus;
+ }
+
/**
* Get the icon given the status and if trust the download status.
*
diff --git a/src/core/features/courses/lang.json b/src/core/features/courses/lang.json
index 47924a0bd..70b5a0b79 100644
--- a/src/core/features/courses/lang.json
+++ b/src/core/features/courses/lang.json
@@ -32,6 +32,7 @@
"password": "Enrolment key",
"paymentrequired": "This course requires a payment for entry.",
"paypalaccepted": "PayPal payments accepted",
+ "refreshcourses": "Refresh courses",
"reload": "Reload",
"removefromfavourites": "Unstar this course",
"search": "Search",
diff --git a/src/core/features/courses/pages/my/my.html b/src/core/features/courses/pages/my/my.html
index cd7224b05..83e679d1a 100644
--- a/src/core/features/courses/pages/my/my.html
+++ b/src/core/features/courses/pages/my/my.html
@@ -9,9 +9,13 @@
-
+ 1"
+ [priority]="1000" [content]="myOverviewBlock?.prefetchCoursesData.statusTranslatable | translate"
+ (action)="myOverviewBlock?.prefetchCourses()"
+ [iconAction]="myOverviewBlock?.prefetchCoursesData.loading ? 'spinner' : myOverviewBlock?.prefetchCoursesData.icon"
+ [badge]="myOverviewBlock?.prefetchCoursesData.badge"
+ [badgeA11yText]="myOverviewBlock?.prefetchCoursesData.badgeA11yText">
+
@@ -26,7 +30,7 @@
+ [extraData]="{'downloadEnabled': true}">
diff --git a/src/core/features/courses/pages/my/my.ts b/src/core/features/courses/pages/my/my.ts
index 09c02acad..9c98a25a4 100644
--- a/src/core/features/courses/pages/my/my.ts
+++ b/src/core/features/courses/pages/my/my.ts
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import { AddonBlockMyOverviewComponent } from '@addons/block/myoverview/components/myoverview/myoverview';
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { CoreBlockComponent } from '@features/block/components/block/block';
import { IonRefresher } from '@ionic/angular';
@@ -19,7 +20,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
-import { CoreCourses, CoreCoursesProvider } from '../../services/courses';
+import { CoreCourses } from '../../services/courses';
/**
* Page that shows a my courses.
@@ -34,28 +35,19 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
@ViewChild(CoreBlockComponent) block!: CoreBlockComponent;
searchEnabled = false;
- downloadEnabled = false;
- downloadCourseEnabled = false;
downloadCoursesEnabled = false;
userId: number;
+ myOverviewBlock?: AddonBlockMyOverviewComponent;
protected updateSiteObserver: CoreEventObserver;
- protected downloadEnabledObserver: CoreEventObserver;
constructor() {
// Refresh the enabled flags if site is updated.
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => {
this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite();
- this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
-
- this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && this.downloadEnabled;
}, CoreSites.getCurrentSiteId());
- this.downloadEnabledObserver = CoreEvents.on(CoreCoursesProvider.EVENT_DASHBOARD_DOWNLOAD_ENABLED_CHANGED, (data) => {
- this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && data.enabled;
- });
-
this.userId = CoreSites.getCurrentSiteUserId();
}
@@ -64,19 +56,23 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
*/
ngOnInit(): void {
this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite();
- this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
- this.downloadEnabled =
- (this.downloadCourseEnabled || this.downloadCoursesEnabled) && CoreCourses.getCourseDownloadOptionsEnabled();
+ this.loadBlock();
}
/**
- * Switch download enabled.
+ * Load my overview block instance.
*/
- switchDownload(): void {
- CoreCourses.setCourseDownloadOptionsEnabled(this.downloadEnabled);
+ protected loadBlock(): void {
+ setTimeout(() => {
+ if (!this.block) {
+ return this.loadBlock();
+ }
+
+ this.myOverviewBlock = this.block?.dynamicComponent?.instance as AddonBlockMyOverviewComponent;
+ }, 500);
}
/**
@@ -111,7 +107,6 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
*/
ngOnDestroy(): void {
this.updateSiteObserver?.off();
- this.downloadEnabledObserver?.off();
}
}