From 080e37013636027b5f853c97acc6f3594667ae6b Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 24 Jan 2022 12:27:12 +0100 Subject: [PATCH] MOBILE-3932 resource: Fix some non-null assertions warnings --- src/addons/mod/book/components/index/index.ts | 2 +- .../course/services/module-prefetch-delegate.ts | 6 +++--- src/core/services/utils/mimetype.ts | 15 ++++++--------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/addons/mod/book/components/index/index.ts b/src/addons/mod/book/components/index/index.ts index d7f78d112..a984af095 100644 --- a/src/addons/mod/book/components/index/index.ts +++ b/src/addons/mod/book/components/index/index.ts @@ -204,7 +204,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp // Chapter loaded, log view. await CoreUtils.ignoreErrors(AddonModBook.logView( - this.module.instance!, + this.module.instance, logChapterId ? chapterId : undefined, this.module.name, )); diff --git a/src/core/features/course/services/module-prefetch-delegate.ts b/src/core/features/course/services/module-prefetch-delegate.ts index a787928db..d75e36759 100644 --- a/src/core/features/course/services/module-prefetch-delegate.ts +++ b/src/core/features/course/services/module-prefetch-delegate.ts @@ -1252,7 +1252,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { if (warning.warningcode == 'missingcallback') { - result[warning.itemid!] = false; + result[warning.itemid || -1] = false; } }); @@ -1304,10 +1304,10 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate 1) { - candidate = split.pop()!.toLowerCase(); + candidate = split[split.length - 1].toLowerCase(); // Remove params if any. position = candidate.indexOf('?'); if (position > -1) { @@ -554,17 +554,14 @@ export class CoreMimetypeUtilsProvider { } extension = this.cleanExtension(extension); + const extensionGroups = this.extToMime[extension] && this.extToMime[extension].groups; + let found = false; - if (groups?.length && this.extToMime[extension]?.groups) { - for (let i = 0; i < this.extToMime[extension].groups!.length; i++) { - const group = this.extToMime[extension].groups![i]; - if (groups.indexOf(group) != -1) { - return true; - } - } + if (groups.length && extensionGroups) { + found = extensionGroups.some((group => groups.includes(group))); } - return false; + return found; } /**