From 3e9326d4774c6b016bd903a43daa3ff82ab01225 Mon Sep 17 00:00:00 2001 From: sam marshall Date: Thu, 16 May 2019 16:10:37 +0100 Subject: [PATCH] MOBILE-2905 Fix bug with NaN appearing for size --- .../pages/course-storage/course-storage.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/addon/storagemanager/pages/course-storage/course-storage.ts b/src/addon/storagemanager/pages/course-storage/course-storage.ts index ed0403151..18769c1c9 100644 --- a/src/addon/storagemanager/pages/course-storage/course-storage.ts +++ b/src/addon/storagemanager/pages/course-storage/course-storage.ts @@ -61,6 +61,7 @@ export class AddonStorageManagerCourseStoragePage { section.totalSize = 0; section.modules.forEach((module) => { module.parentSection = section; + module.totalSize = 0; // Note: This function only gets the size for modules which are downloadable. // For other modules it always returns 0, even if they have downloaded some files. // However there is no 100% reliable way to actually track the files in this case. @@ -70,9 +71,12 @@ export class AddonStorageManagerCourseStoragePage { // Most modules which have large files are downloadable, so I think this is sufficient. const promise = this.prefetchDelegate.getModuleDownloadedSize(module, this.course.id). then((size) => { - module.totalSize = size; - section.totalSize += size; - this.totalSize += size; + // There are some cases where the return from this is not a valid number. + if (!isNaN(size)) { + module.totalSize = Number(size); + section.totalSize += size; + this.totalSize += size; + } }); allPromises.push(promise); });