diff --git a/src/components/site-picker/site-picker.ts b/src/components/site-picker/site-picker.ts index dca537560..60bfd17e5 100644 --- a/src/components/site-picker/site-picker.ts +++ b/src/components/site-picker/site-picker.ts @@ -51,7 +51,7 @@ export class CoreSitePickerComponent implements OnInit { sites.forEach((site: any) => { // Format the site name. promises.push(this.filterProvider.formatText(site.siteName, {clean: true, singleLine: true, filter: false}, [], - site.getId()).catch(() => { + site.id).catch(() => { return site.siteName; }).then((siteName) => { site.fullNameAndSiteName = this.translate.instant('core.fullnameandsitename', diff --git a/src/directives/format-text.ts b/src/directives/format-text.ts index 54e627c9f..9c4a8c314 100644 --- a/src/directives/format-text.ts +++ b/src/directives/format-text.ts @@ -404,7 +404,10 @@ export class CoreFormatTextDirective implements OnChanges { // Error getting the site. This probably means that there is no current site and no siteId was supplied. }).then((siteInstance: CoreSite) => { site = siteInstance; - result.siteId = site.getId(); + + if (site) { + result.siteId = site.getId(); + } if (this.contextLevel == 'course' && this.contextInstanceId <= 0) { this.contextInstanceId = site.getSiteHomeId(); @@ -422,14 +425,14 @@ export class CoreFormatTextDirective implements OnChanges { if (this.filter) { return this.filterHelper.getFiltersAndFormatText(this.text, this.contextLevel, this.contextInstanceId, - result.options, site.getId()).then((res) => { + result.options, result.siteId).then((res) => { result.filters = res.filters; return res.text; }); } else { - return this.filterProvider.formatText(this.text, result.options, [], site.getId()); + return this.filterProvider.formatText(this.text, result.options, [], result.siteId); } }).then((formatted) => {