MOBILE-3811 resource: Remove mimetype icons from resource

main
Pau Ferrer Ocaña 2022-01-18 12:10:21 +01:00
parent 8c82446027
commit 96b172c42c
1 changed files with 4 additions and 48 deletions

View File

@ -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<AddonResourceHandlerData> {
): Promise<string> {
const promises: Promise<void>[] = [];
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<string | undefined> {
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;
}
;