MOBILE-3320 course: Fix course downloaded icon

main
Noel De Martin 2021-06-21 15:44:23 +02:00
parent b1db34ebaa
commit aa106f3728
5 changed files with 27 additions and 8 deletions

View File

@ -477,7 +477,12 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy {
* @param status Status to show. * @param status Status to show.
*/ */
protected updateCourseStatus(status: string): void { 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;
} }
/** /**

View File

@ -402,7 +402,12 @@ export class CoreCoursePreviewPage implements OnInit, OnDestroy {
* @param status Status to show. * @param status Status to show.
*/ */
protected updateCourseStatus(status: string): void { 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;
} }
/** /**

View File

@ -1163,7 +1163,7 @@ export class CoreCourseHelperProvider {
const status = await this.determineCoursesStatus(courses); const status = await this.determineCoursesStatus(courses);
prefetch = this.getCourseStatusIconAndTitleFromStatus(status); prefetch = this.getCoursePrefetchStatusInfo(status);
if (prefetch.loading) { if (prefetch.loading) {
// It seems all courses are being downloaded, show a download button instead. // 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<CorePrefetchStatusInfo> { async getCourseStatusIconAndTitle(courseId: number, siteId?: string): Promise<CorePrefetchStatusInfo> {
const status = await CoreCourse.getCourseStatus(courseId, siteId); 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. * Get a course status icon and the langkey to use as a title from status.
* *
* @param status Course 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 = { const prefetchStatus: CorePrefetchStatusInfo = {
status: status, status: status,
icon: this.getPrefetchStatusIcon(status, false), icon: this.getPrefetchStatusIcon(status, false),

View File

@ -49,6 +49,11 @@
<ion-spinner *ngIf="(downloadCourseEnabled && prefetchCourseData.icon == 'spinner') || showSpinner" <ion-spinner *ngIf="(downloadCourseEnabled && prefetchCourseData.icon == 'spinner') || showSpinner"
[attr.aria-label]="'core.loading' | translate"></ion-spinner> [attr.aria-label]="'core.loading' | translate"></ion-spinner>
<!-- Downloaded icon. -->
<ion-icon *ngIf="downloadCourseEnabled && prefetchCourseData.downloadSucceeded && !showSpinner"
class="core-icon-downloaded" name="cloud-done" color="success" role="status"
[attr.aria-label]="'core.downloaded' | translate"></ion-icon>
<!-- Options menu. --> <!-- Options menu. -->
<ion-button fill="clear" color="dark" (click)="showCourseOptionsMenu($event)" *ngIf="!showSpinner" <ion-button fill="clear" color="dark" (click)="showCourseOptionsMenu($event)" *ngIf="!showSpinner"
[attr.aria-label]="('core.displayoptions' | translate)"> [attr.aria-label]="('core.displayoptions' | translate)">

View File

@ -107,7 +107,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
// Determine course prefetch icon. // Determine course prefetch icon.
const status = await CoreCourse.getCourseStatus(this.course.id); const status = await CoreCourse.getCourseStatus(this.course.id);
this.prefetchCourseData = CoreCourseHelper.getCourseStatusIconAndTitleFromStatus(status); this.prefetchCourseData = CoreCourseHelper.getCoursePrefetchStatusInfo(status);
this.courseStatus = status; this.courseStatus = status;
if (this.prefetchCourseData.loading) { if (this.prefetchCourseData.loading) {
@ -184,9 +184,13 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
* @param status Status to show. * @param status Status to show.
*/ */
protected updateCourseStatus(status: string): void { protected updateCourseStatus(status: string): void {
this.prefetchCourseData = CoreCourseHelper.getCourseStatusIconAndTitleFromStatus(status); const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status);
this.courseStatus = status; this.courseStatus = status;
this.prefetchCourseData.status = statusData.status;
this.prefetchCourseData.icon = statusData.icon;
this.prefetchCourseData.statusTranslatable = statusData.statusTranslatable;
this.prefetchCourseData.loading = statusData.loading;
} }
/** /**