MOBILE-2567 lti: Fix LTI icons not displayed

main
Dani Palou 2018-09-03 16:42:29 +02:00
parent 9d09a31af5
commit a0d76b9370
2 changed files with 7 additions and 4 deletions

View File

@ -14,6 +14,7 @@
import { Injectable } from '@angular/core';
import { NavController, NavOptions } from 'ionic-angular';
import { DomSanitizer } from '@angular/platform-browser';
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate';
import { CoreAppProvider } from '@providers/app';
import { CoreCourseProvider } from '@core/course/providers/course';
@ -36,7 +37,8 @@ export class AddonModLtiModuleHandler implements CoreCourseModuleHandler {
private domUtils: CoreDomUtilsProvider,
private filepoolProvider: CoreFilepoolProvider,
private sitesProvider: CoreSitesProvider,
private ltiProvider: AddonModLtiProvider) {}
private ltiProvider: AddonModLtiProvider,
private sanitizer: DomSanitizer) {}
/**
* Check if the handler is enabled on a site level.
@ -100,11 +102,11 @@ export class AddonModLtiModuleHandler implements CoreCourseModuleHandler {
// Get the internal URL.
return this.filepoolProvider.getSrcByUrl(siteId, icon, AddonModLtiProvider.COMPONENT, module.id);
}).then((url) => {
data.icon = url;
data.icon = this.sanitizer.bypassSecurityTrustUrl(url);
}).catch(() => {
// Error downloading. If we're online we'll set the online url.
if (this.appProvider.isOnline()) {
data.icon = icon;
data.icon = this.sanitizer.bypassSecurityTrustUrl(icon);
}
});
}

View File

@ -14,6 +14,7 @@
import { Injectable, Injector } from '@angular/core';
import { NavController, NavOptions } from 'ionic-angular';
import { SafeUrl } from '@angular/platform-browser';
import { CoreEventsProvider } from '@providers/events';
import { CoreLoggerProvider } from '@providers/logger';
import { CoreSitesProvider } from '@providers/sites';
@ -77,7 +78,7 @@ export interface CoreCourseModuleHandlerData {
* The image to use as icon (path to the image).
* @type {string}
*/
icon?: string;
icon?: string | SafeUrl;
/**
* The class to assign to the item.