From aa106f3728c90603459863bca9595f0449e8d264 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Mon, 21 Jun 2021 15:44:23 +0200 Subject: [PATCH] MOBILE-3320 course: Fix course downloaded icon --- src/core/features/course/pages/contents/contents.ts | 7 ++++++- src/core/features/course/pages/preview/preview.page.ts | 7 ++++++- src/core/features/course/services/course-helper.ts | 8 ++++---- .../course-progress/core-courses-course-progress.html | 5 +++++ .../courses/components/course-progress/course-progress.ts | 8 ++++++-- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/core/features/course/pages/contents/contents.ts b/src/core/features/course/pages/contents/contents.ts index 3cf7f8da6..0fafde5ef 100644 --- a/src/core/features/course/pages/contents/contents.ts +++ b/src/core/features/course/pages/contents/contents.ts @@ -477,7 +477,12 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy { * @param status Status to show. */ protected updateCourseStatus(status: string): void { - this.prefetchCourseData = CoreCourseHelper.getCourseStatusIconAndTitleFromStatus(status); + const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status); + + this.prefetchCourseData.status = statusData.status; + this.prefetchCourseData.icon = statusData.icon; + this.prefetchCourseData.statusTranslatable = statusData.statusTranslatable; + this.prefetchCourseData.loading = statusData.loading; } /** diff --git a/src/core/features/course/pages/preview/preview.page.ts b/src/core/features/course/pages/preview/preview.page.ts index f235d620e..32ddc47e2 100644 --- a/src/core/features/course/pages/preview/preview.page.ts +++ b/src/core/features/course/pages/preview/preview.page.ts @@ -402,7 +402,12 @@ export class CoreCoursePreviewPage implements OnInit, OnDestroy { * @param status Status to show. */ protected updateCourseStatus(status: string): void { - this.prefetchCourseData = CoreCourseHelper.getCourseStatusIconAndTitleFromStatus(status); + const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status); + + this.prefetchCourseData.status = statusData.status; + this.prefetchCourseData.icon = statusData.icon; + this.prefetchCourseData.statusTranslatable = statusData.statusTranslatable; + this.prefetchCourseData.loading = statusData.loading; } /** diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts index 64d1d832d..7e7dcd319 100644 --- a/src/core/features/course/services/course-helper.ts +++ b/src/core/features/course/services/course-helper.ts @@ -1163,7 +1163,7 @@ export class CoreCourseHelperProvider { const status = await this.determineCoursesStatus(courses); - prefetch = this.getCourseStatusIconAndTitleFromStatus(status); + prefetch = this.getCoursePrefetchStatusInfo(status); if (prefetch.loading) { // It seems all courses are being downloaded, show a download button instead. @@ -1298,16 +1298,16 @@ export class CoreCourseHelperProvider { async getCourseStatusIconAndTitle(courseId: number, siteId?: string): Promise { const status = await CoreCourse.getCourseStatus(courseId, siteId); - return this.getCourseStatusIconAndTitleFromStatus(status); + return this.getCoursePrefetchStatusInfo(status); } /** * Get a course status icon and the langkey to use as a title from status. * * @param status Course status. - * @return Title and icon name. + * @return Prefetch status info. */ - getCourseStatusIconAndTitleFromStatus(status: string): CorePrefetchStatusInfo { + getCoursePrefetchStatusInfo(status: string): CorePrefetchStatusInfo { const prefetchStatus: CorePrefetchStatusInfo = { status: status, icon: this.getPrefetchStatusIcon(status, false), diff --git a/src/core/features/courses/components/course-progress/core-courses-course-progress.html b/src/core/features/courses/components/course-progress/core-courses-course-progress.html index b3c6edd41..9dd5128b4 100644 --- a/src/core/features/courses/components/course-progress/core-courses-course-progress.html +++ b/src/core/features/courses/components/course-progress/core-courses-course-progress.html @@ -49,6 +49,11 @@ + + + diff --git a/src/core/features/courses/components/course-progress/course-progress.ts b/src/core/features/courses/components/course-progress/course-progress.ts index de922c200..7109ad66c 100644 --- a/src/core/features/courses/components/course-progress/course-progress.ts +++ b/src/core/features/courses/components/course-progress/course-progress.ts @@ -107,7 +107,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy { // Determine course prefetch icon. const status = await CoreCourse.getCourseStatus(this.course.id); - this.prefetchCourseData = CoreCourseHelper.getCourseStatusIconAndTitleFromStatus(status); + this.prefetchCourseData = CoreCourseHelper.getCoursePrefetchStatusInfo(status); this.courseStatus = status; if (this.prefetchCourseData.loading) { @@ -184,9 +184,13 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy { * @param status Status to show. */ protected updateCourseStatus(status: string): void { - this.prefetchCourseData = CoreCourseHelper.getCourseStatusIconAndTitleFromStatus(status); + const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status); this.courseStatus = status; + this.prefetchCourseData.status = statusData.status; + this.prefetchCourseData.icon = statusData.icon; + this.prefetchCourseData.statusTranslatable = statusData.statusTranslatable; + this.prefetchCourseData.loading = statusData.loading; } /**