From 96b172c42ca216aacc986502eb628e5a911d0671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 18 Jan 2022 12:10:21 +0100 Subject: [PATCH] MOBILE-3811 resource: Remove mimetype icons from resource --- .../mod/resource/services/handlers/module.ts | 52 ++----------------- 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/src/addons/mod/resource/services/handlers/module.ts b/src/addons/mod/resource/services/handlers/module.ts index 85cc81e0b..a889ac9ed 100644 --- a/src/addons/mod/resource/services/handlers/module.ts +++ b/src/addons/mod/resource/services/handlers/module.ts @@ -93,9 +93,8 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase }, }]; - this.getResourceData(module, courseId, handlerData).then((data) => { - handlerData.icon = data.icon; - handlerData.extraBadge = data.extra; + this.getResourceData(module, courseId, handlerData).then((extra) => { + handlerData.extraBadge = extra; handlerData.extraBadgeColor = 'light'; return; @@ -133,7 +132,7 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase module: CoreCourseModuleData, courseId: number, handlerData: CoreCourseModuleHandlerData, - ): Promise { + ): Promise { const promises: Promise[] = []; let options: AddonModResourceCustomData = {}; @@ -161,23 +160,15 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase await Promise.all(promises); - let mimetypeIcon = ''; const extra: string[] = []; if (module.contentsinfo) { // No need to use the list of files. - const mimetype = module.contentsinfo.mimetypes[0]; - if (mimetype) { - mimetypeIcon = CoreMimetypeUtils.getMimetypeIcon(mimetype); - } extra.push(CoreTextUtils.cleanTags(module.afterlink)); - } else if (module.contents && module.contents[0]) { const files = module.contents; const file = files[0]; - mimetypeIcon = CoreMimetypeUtils.getFileIcon(file.filename || ''); - if (options.showsize) { const size = options.filedetails ? options.filedetails.size @@ -220,36 +211,7 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase } } - return { - icon: await CoreCourse.getModuleIconSrc(module.modname, module.modicon, mimetypeIcon), - extra: extra.join(' '), - }; - } - - /** - * @inheritdoc - */ - async getIconSrc(module?: CoreCourseModuleData): Promise { - if (!module) { - return; - } - let mimetypeIcon = ''; - - if (module.contentsinfo) { - // No need to use the list of files. - const mimetype = module.contentsinfo.mimetypes[0]; - if (mimetype) { - mimetypeIcon = CoreMimetypeUtils.getMimetypeIcon(mimetype); - } - - } else if (module.contents && module.contents[0]) { - const files = module.contents; - const file = files[0]; - - mimetypeIcon = CoreMimetypeUtils.getFileIcon(file.filename || ''); - } - - return await CoreCourse.getModuleIconSrc(module.modname, module.modicon, mimetypeIcon); + return extra.join(' '); } /** @@ -261,9 +223,3 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase } export const AddonModResourceModuleHandler = makeSingleton(AddonModResourceModuleHandlerService); - -type AddonResourceHandlerData = { - icon: string; - extra: string; -} -;