From 9527f00ca1198fcc7473c80b92f611ad59842bfd Mon Sep 17 00:00:00 2001 From: dpalou Date: Fri, 28 Sep 2018 08:22:15 +0200 Subject: [PATCH] MOBILE-2641 resource: Fix icons in sites older than 3.1 --- src/addon/mod/resource/providers/module-handler.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/addon/mod/resource/providers/module-handler.ts b/src/addon/mod/resource/providers/module-handler.ts index b44775b42..8976ba2cf 100644 --- a/src/addon/mod/resource/providers/module-handler.ts +++ b/src/addon/mod/resource/providers/module-handler.ts @@ -129,18 +129,20 @@ export class AddonModResourceModuleHandler implements CoreCourseModuleHandler { handlerData.buttons[0].hidden = hideOpenButton; })); - // Get the resource data. - promises.push(this.resourceProvider.getResourceData(courseId, module.id).then((info) => { - resourceInfo = info; - })); + if (this.resourceProvider.isGetResourceWSAvailable()) { + // Get the resource data. + promises.push(this.resourceProvider.getResourceData(courseId, module.id).then((info) => { + resourceInfo = info; + })); + } return Promise.all(promises).then(() => { - const files = module.contents && module.contents.length ? module.contents : resourceInfo.contentfiles, + const files = module.contents && module.contents.length ? module.contents : resourceInfo && resourceInfo.contentfiles, resourceData = { icon: '', extra: '' }, - options = this.textUtils.unserialize(resourceInfo.displayoptions), + options = (resourceInfo && this.textUtils.unserialize(resourceInfo.displayoptions)) || {}, extra = []; if (files && files.length) {