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) => { this.getResourceData(module, courseId, handlerData).then((extra) => {
handlerData.icon = data.icon; handlerData.extraBadge = extra;
handlerData.extraBadge = data.extra;
handlerData.extraBadgeColor = 'light'; handlerData.extraBadgeColor = 'light';
return; return;
@ -133,7 +132,7 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
module: CoreCourseModuleData, module: CoreCourseModuleData,
courseId: number, courseId: number,
handlerData: CoreCourseModuleHandlerData, handlerData: CoreCourseModuleHandlerData,
): Promise<AddonResourceHandlerData> { ): Promise<string> {
const promises: Promise<void>[] = []; const promises: Promise<void>[] = [];
let options: AddonModResourceCustomData = {}; let options: AddonModResourceCustomData = {};
@ -161,23 +160,15 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
await Promise.all(promises); await Promise.all(promises);
let mimetypeIcon = '';
const extra: string[] = []; const extra: string[] = [];
if (module.contentsinfo) { if (module.contentsinfo) {
// No need to use the list of files. // 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)); extra.push(CoreTextUtils.cleanTags(module.afterlink));
} else if (module.contents && module.contents[0]) { } else if (module.contents && module.contents[0]) {
const files = module.contents; const files = module.contents;
const file = files[0]; const file = files[0];
mimetypeIcon = CoreMimetypeUtils.getFileIcon(file.filename || '');
if (options.showsize) { if (options.showsize) {
const size = options.filedetails const size = options.filedetails
? options.filedetails.size ? options.filedetails.size
@ -220,36 +211,7 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
} }
} }
return { return extra.join(' ');
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);
} }
/** /**
@ -261,9 +223,3 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
} }
export const AddonModResourceModuleHandler = makeSingleton(AddonModResourceModuleHandlerService); export const AddonModResourceModuleHandler = makeSingleton(AddonModResourceModuleHandlerService);
type AddonResourceHandlerData = {
icon: string;
extra: string;
}
;