MOBILE-3899 core: Fix non-null assertion warnings on linter
parent
3feee9e831
commit
dc2bbe8af1
|
@ -63,7 +63,7 @@ export class CoreH5PIframeComponent implements OnChanges, OnDestroy {
|
|||
) {
|
||||
|
||||
this.logger = CoreLogger.getInstance('CoreH5PIframeComponent');
|
||||
this.site = CoreSites.getCurrentSite()!;
|
||||
this.site = CoreSites.getRequiredCurrentSite();
|
||||
this.siteId = this.site.getId();
|
||||
this.siteCanDownload = this.site.canDownloadFiles() && !CoreH5P.isOfflineDisabledInSite();
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ export class CoreTextUtilsProvider {
|
|||
// First, we use a regexpr.
|
||||
text = text.replace(/(<([^>]+)>)/ig, '');
|
||||
// Then, we rely on the browser. We need to wrap the text to be sure is HTML.
|
||||
text = this.convertToElement(text).textContent!;
|
||||
text = this.convertToElement(text).textContent || '';
|
||||
// Recover or remove new lines.
|
||||
text = this.replaceNewLines(text, singleLine ? ' ' : '<br>');
|
||||
|
||||
|
@ -370,7 +370,7 @@ export class CoreTextUtilsProvider {
|
|||
*/
|
||||
decodeHTMLEntities(text: string): string {
|
||||
if (text) {
|
||||
text = this.convertToElement(text).textContent!;
|
||||
text = this.convertToElement(text).textContent || '';
|
||||
}
|
||||
|
||||
return text;
|
||||
|
|
|
@ -295,19 +295,19 @@ export class CoreTimeUtilsProvider {
|
|||
* @return Readable date.
|
||||
*/
|
||||
userDate(timestamp: number, format?: string, convert: boolean = true, fixDay: boolean = true, fixHour: boolean = true): string {
|
||||
format = Translate.instant(format ? format : 'core.strftimedaydatetime');
|
||||
format = Translate.instant(format ? format : 'core.strftimedaydatetime') as string;
|
||||
|
||||
if (fixDay) {
|
||||
format = format!.replace(/%d/g, '%e');
|
||||
format = format.replace(/%d/g, '%e');
|
||||
}
|
||||
|
||||
if (fixHour) {
|
||||
format = format!.replace('%I', '%l');
|
||||
format = format.replace('%I', '%l');
|
||||
}
|
||||
|
||||
// Format could be in PHP format, convert it to moment.
|
||||
if (convert) {
|
||||
format = this.convertPHPToMoment(format!);
|
||||
format = this.convertPHPToMoment(format);
|
||||
}
|
||||
|
||||
return moment(timestamp).format(format);
|
||||
|
|
|
@ -64,7 +64,12 @@ export class CoreColors {
|
|||
document.body.appendChild(d);
|
||||
|
||||
// Color in RGB .
|
||||
const rgba = getComputedStyle(d).color.match(/\d+/g)!.map((a) => parseInt(a, 10));
|
||||
const matches = getComputedStyle(d).color.match(/\d+/g) || [];
|
||||
if (matches.length == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const rgba = matches.map((a) => parseInt(a, 10));
|
||||
|
||||
const hex = [0,1,2].map(
|
||||
(idx) => this.componentToHex(rgba[idx]),
|
||||
|
@ -72,7 +77,7 @@ export class CoreColors {
|
|||
|
||||
document.body.removeChild(d);
|
||||
|
||||
return '#'+hex;
|
||||
return '#' + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue