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