From ab95e1d75982f4cee79fa92b89e87cba1b3efc09 Mon Sep 17 00:00:00 2001 From: Alfonso Date: Wed, 30 Mar 2022 15:28:38 +0200 Subject: [PATCH] MOBILE-3833 module-summary: format file size to readable size only when requires it --- .../components/module-summary/module-summary.html | 8 ++++---- .../components/module-summary/module-summary.ts | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/core/features/course/components/module-summary/module-summary.html b/src/core/features/course/components/module-summary/module-summary.html index 7af594e4b..8bd270c5e 100644 --- a/src/core/features/course/components/module-summary/module-summary.html +++ b/src/core/features/course/components/module-summary/module-summary.html @@ -153,7 +153,7 @@ - +

@@ -162,13 +162,13 @@

- +

{{ 'addon.storagemanager.totalspaceusage' | translate }}

- {{ sizeReadable | coreBytesToSize }} + {{ size | coreBytesToSize }}
+ [attr.aria-label]="'core.clearstoreddata' | translate:{$a: size | coreBytesToSize}" slot="end"> diff --git a/src/core/features/course/components/module-summary/module-summary.ts b/src/core/features/course/components/module-summary/module-summary.ts index 61e5695cf..7a399e8c1 100644 --- a/src/core/features/course/components/module-summary/module-summary.ts +++ b/src/core/features/course/components/module-summary/module-summary.ts @@ -62,7 +62,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { prefetchLoading = false; canPrefetch = false;; prefetchDisabled = false; - sizeReadable = ''; + size?: number; // Size in bytes downloadTimeReadable = ''; // Last download time in a readable format. grades?: CoreGradesFormattedRow[]; blog = false; // If blog is available. @@ -137,7 +137,9 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { const moduleSize = await CoreCourseModulePrefetchDelegate.getModuleStoredSize(this.module, this.courseId); - this.sizeReadable = moduleSize > 0 ? CoreTextUtils.bytesToSize(moduleSize, 2) : ''; + if (moduleSize) { + this.size = moduleSize; + } }, 1000); this.fileStatusObserver = CoreEvents.on( @@ -211,9 +213,9 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { this.prefetchDisabled = moduleInfo.status == CoreConstants.DOWNLOADED; } - this.sizeReadable = moduleInfo.size && moduleInfo.size > 0 - ? moduleInfo.sizeReadable - : ''; + if (moduleInfo.size && moduleInfo.size > 0) { + this.size = moduleInfo.size; + } } /**