Merge pull request #1915 from sammarshallou/MOBILE-2905

MOBILE-2905 Fix bug with NaN appearing for size
main
Juan Leyva 2019-05-16 17:49:42 +02:00 committed by GitHub
commit 6dd8786da6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -61,6 +61,7 @@ export class AddonStorageManagerCourseStoragePage {
section.totalSize = 0; section.totalSize = 0;
section.modules.forEach((module) => { section.modules.forEach((module) => {
module.parentSection = section; module.parentSection = section;
module.totalSize = 0;
// Note: This function only gets the size for modules which are downloadable. // 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. // 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. // 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. // Most modules which have large files are downloadable, so I think this is sufficient.
const promise = this.prefetchDelegate.getModuleDownloadedSize(module, this.course.id). const promise = this.prefetchDelegate.getModuleDownloadedSize(module, this.course.id).
then((size) => { then((size) => {
module.totalSize = size; // There are some cases where the return from this is not a valid number.
section.totalSize += size; if (!isNaN(size)) {
this.totalSize += size; module.totalSize = Number(size);
section.totalSize += size;
this.totalSize += size;
}
}); });
allPromises.push(promise); allPromises.push(promise);
}); });