MOBILE-3947 chore: Fix some non valid types
parent
1639e60ebe
commit
9e9052db85
|
@ -44,7 +44,7 @@ export class AddonBlockTimelineSection {
|
|||
this.overdue = overdue;
|
||||
this.dateRange = dateRange;
|
||||
this.course = course;
|
||||
this.dataSubject$ = new BehaviorSubject({
|
||||
this.dataSubject$ = new BehaviorSubject<AddonBlockTimelineSectionData>({
|
||||
events: [],
|
||||
lastEventId: canLoadMore,
|
||||
canLoadMore: typeof canLoadMore !== 'undefined',
|
||||
|
|
|
@ -56,7 +56,7 @@ export class AddonBlockTimelineComponent implements OnInit, ICoreBlockComponent
|
|||
|
||||
constructor() {
|
||||
this.logger = CoreLogger.getInstance('AddonBlockTimelineComponent');
|
||||
this.search$ = new BehaviorSubject(null);
|
||||
this.search$ = new BehaviorSubject<string | null>(null);
|
||||
this.initializeSort();
|
||||
this.initializeFilter();
|
||||
this.initializeSections();
|
||||
|
|
|
@ -98,7 +98,7 @@ export class AddonEnrolGuestHandlerService implements CoreEnrolGuestHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
const validatePassword = async (password: string): Promise<CorePasswordModalResponse> => {
|
||||
const validatePassword = async (password = ''): Promise<CorePasswordModalResponse> => {
|
||||
const modal = await CoreDomUtils.showModalLoading('core.loading', true);
|
||||
|
||||
try {
|
||||
|
|
|
@ -407,8 +407,8 @@ type MathJaxWindow = Window & {
|
|||
MathJax?: any; // eslint-disable-line @typescript-eslint/naming-convention, @typescript-eslint/no-explicit-any
|
||||
M?: { // eslint-disable-line @typescript-eslint/naming-convention
|
||||
filter_mathjaxloader?: { // eslint-disable-line @typescript-eslint/naming-convention
|
||||
_lang: ''; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
_configured: false; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
_lang: string; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
_configured: boolean; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
// Add the configuration to the head and set the lang.
|
||||
configure: (params: Record<string, unknown>) => void;
|
||||
_setLocale: () => void; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
|
|
|
@ -28,6 +28,7 @@ import {
|
|||
SUBMISSIONS_GRADES_TABLE,
|
||||
SUBMISSIONS_TABLE,
|
||||
} from './database/assign';
|
||||
import { CoreArray } from '@singletons/array';
|
||||
|
||||
/**
|
||||
* Service to handle offline assign.
|
||||
|
@ -86,8 +87,8 @@ export class AddonModAssignOfflineProvider {
|
|||
|
||||
const results = await Promise.all(promises);
|
||||
// Flatten array.
|
||||
const flatten: (AddonModAssignSubmissionsDBRecord | AddonModAssignSubmissionsGradingDBRecord)[] =
|
||||
[].concat.apply([], results);
|
||||
const flatten = CoreArray
|
||||
.flatten<AddonModAssignSubmissionsDBRecordFormatted | AddonModAssignSubmissionsGradingDBRecordFormatted>(results);
|
||||
|
||||
// Get assign id.
|
||||
let assignIds: number[] = flatten.map((assign) => assign.assignid);
|
||||
|
|
|
@ -166,7 +166,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
|
|||
|
||||
// Get intro and activity files from the submission status if it's a student.
|
||||
// It's ok if they were already obtained from the assignment instance, they won't be downloaded twice.
|
||||
const files = canViewAllSubmissions ?
|
||||
const files: CoreWSFile[] = canViewAllSubmissions ?
|
||||
[] :
|
||||
(submissionStatus.assignmentdata?.attachments?.intro || [])
|
||||
.concat(submissionStatus.assignmentdata?.attachments?.activity || []);
|
||||
|
|
|
@ -301,7 +301,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo
|
|||
this.data = [];
|
||||
this.labels = [];
|
||||
|
||||
this.results = results.map((result: AddonModChoiceResultFormatted) => {
|
||||
this.results = results.map<AddonModChoiceResultFormatted>((result) => {
|
||||
if (result.numberofuser > 0) {
|
||||
hasVotes = true;
|
||||
}
|
||||
|
|
|
@ -194,9 +194,9 @@ export class AddonModFeedbackProvider {
|
|||
}
|
||||
|
||||
// Treat multichoice checkboxes.
|
||||
if (item.typ == 'multichoice' && item.presentation.split(AddonModFeedbackProvider.MULTICHOICE_TYPE_SEP)[0] == 'c') {
|
||||
if (item.typ === 'multichoice' && item.presentation.split(AddonModFeedbackProvider.MULTICHOICE_TYPE_SEP)[0] === 'c') {
|
||||
|
||||
offlineValues[item.id] = offlineValues[item.id].filter((value) => value > 0);
|
||||
offlineValues[item.id] = offlineValues[item.id].filter((value) => Number(value) > 0);
|
||||
item.rawValue = offlineValues[item.id].join(AddonModFeedbackProvider.LINE_SEP);
|
||||
} else {
|
||||
item.rawValue = offlineValues[item.id][0];
|
||||
|
|
|
@ -513,7 +513,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea
|
|||
published: boolean;
|
||||
} = this.feedbackForm.value;
|
||||
|
||||
inputData.grade = inputData.grade >= 0 ? inputData.grade : '';
|
||||
inputData.grade = Number(inputData.grade) >= 0 ? inputData.grade : '';
|
||||
// Add some HTML to the message if needed.
|
||||
inputData.text = CoreTextUtils.formatHtmlLines(inputData.text);
|
||||
|
||||
|
|
|
@ -348,8 +348,8 @@ export class CoreDatabaseTable<
|
|||
|
||||
records.sort((a, b) => {
|
||||
for (const [column, direction] of columnsSorting) {
|
||||
const aValue = a[column];
|
||||
const bValue = b[column];
|
||||
const aValue = a[column] ?? 0;
|
||||
const bValue = b[column] ?? 0;
|
||||
|
||||
if (aValue > bValue) {
|
||||
return direction === 'desc' ? -1 : 1;
|
||||
|
|
|
@ -40,7 +40,7 @@ export class CoreSplitViewComponent implements AfterViewInit, OnDestroy {
|
|||
isNested = false;
|
||||
disabledScrollOuterContents: HTMLIonContentElement[] = [];
|
||||
|
||||
private outletRouteSubject: BehaviorSubject<ActivatedRouteSnapshot | null> = new BehaviorSubject(null);
|
||||
private outletRouteSubject = new BehaviorSubject<ActivatedRouteSnapshot | null>(null);
|
||||
private subscriptions?: Subscription[];
|
||||
|
||||
constructor(private element: ElementRef<HTMLElement>) {}
|
||||
|
|
|
@ -464,11 +464,13 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec
|
|||
const audios = Array.from(div.querySelectorAll('audio'));
|
||||
const videos = Array.from(div.querySelectorAll('video'));
|
||||
const iframes = Array.from(div.querySelectorAll('iframe'));
|
||||
const buttons = Array.from(div.querySelectorAll('.button'));
|
||||
const buttons = Array.from(div.querySelectorAll<HTMLElement>('.button'));
|
||||
const icons = Array.from(div.querySelectorAll('i.fa,i.fas,i.far,i.fab'));
|
||||
const elementsWithInlineStyles = Array.from(div.querySelectorAll('*[style]'));
|
||||
const stopClicksElements = Array.from(div.querySelectorAll('button,input,select,textarea'));
|
||||
const frames = Array.from(div.querySelectorAll(CoreIframeUtilsProvider.FRAME_TAGS.join(',').replace(/iframe,?/, '')));
|
||||
const elementsWithInlineStyles = Array.from(div.querySelectorAll<HTMLElement>('*[style]'));
|
||||
const stopClicksElements = Array.from(div.querySelectorAll<HTMLElement>('button,input,select,textarea'));
|
||||
const frames = Array.from(
|
||||
div.querySelectorAll<FrameElement>(CoreIframeUtilsProvider.FRAME_TAGS.join(',').replace(/iframe,?/, '')),
|
||||
);
|
||||
const svgImages = Array.from(div.querySelectorAll('image'));
|
||||
const promises: Promise<void>[] = [];
|
||||
|
||||
|
@ -560,7 +562,7 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec
|
|||
});
|
||||
|
||||
// Handle all kind of frames.
|
||||
const frameControllers = frames.map((frame: FrameElement) => {
|
||||
const frameControllers = frames.map<FrameElementController>((frame) => {
|
||||
CoreIframeUtils.treatFrame(frame, false);
|
||||
|
||||
return new FrameElementController(frame, !this.disabled);
|
||||
|
|
|
@ -17,6 +17,7 @@ import { CoreSites } from '@services/sites';
|
|||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { COMMENTS_TABLE, COMMENTS_DELETED_TABLE, CoreCommentsDBRecord, CoreCommentsDeletedDBRecord } from './database/comments';
|
||||
import { CoreArray } from '@singletons/array';
|
||||
|
||||
/**
|
||||
* Service to handle offline comments.
|
||||
|
@ -33,11 +34,11 @@ export class CoreCommentsOfflineProvider {
|
|||
async getAllComments(siteId?: string): Promise<(CoreCommentsDBRecord | CoreCommentsDeletedDBRecord)[]> {
|
||||
const site = await CoreSites.getSite(siteId);
|
||||
const results = await Promise.all([
|
||||
site.getDb().getRecords(COMMENTS_TABLE),
|
||||
site.getDb().getRecords(COMMENTS_DELETED_TABLE),
|
||||
site.getDb().getRecords<CoreCommentsDBRecord>(COMMENTS_TABLE),
|
||||
site.getDb().getRecords<CoreCommentsDeletedDBRecord>(COMMENTS_DELETED_TABLE),
|
||||
]);
|
||||
|
||||
return [].concat.apply([], results);
|
||||
return CoreArray.flatten<CoreCommentsDBRecord | CoreCommentsDeletedDBRecord>(results);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,7 +48,7 @@ export class CoreFileUploaderAudioRecorderComponent extends CoreModalComponent<C
|
|||
super(elementRef);
|
||||
|
||||
this.recording = null;
|
||||
this.media$ = new BehaviorSubject(null);
|
||||
this.media$ = new BehaviorSubject<AudioRecorderMedia | null>(null);
|
||||
this.recording$ = this.media$.pipe(
|
||||
recorderAudioRecording(),
|
||||
shareReplay(),
|
||||
|
|
|
@ -51,15 +51,16 @@ export class CoreReportBuilderReportDetailComponent implements OnInit {
|
|||
return this.layout === 'card' || (CoreScreen.isMobile && this.layout === 'adaptative');
|
||||
}
|
||||
|
||||
state$: Readonly<BehaviorSubject<CoreReportBuilderReportDetailState>> = new BehaviorSubject({
|
||||
report: null,
|
||||
loaded: false,
|
||||
canLoadMoreRows: true,
|
||||
errorLoadingRows: false,
|
||||
cardviewShowFirstTitle: false,
|
||||
cardVisibleColumns: 1,
|
||||
page: 0,
|
||||
});
|
||||
state$: Readonly<BehaviorSubject<CoreReportBuilderReportDetailState>> =
|
||||
new BehaviorSubject<CoreReportBuilderReportDetailState>({
|
||||
report: null,
|
||||
loaded: false,
|
||||
canLoadMoreRows: true,
|
||||
errorLoadingRows: false,
|
||||
cardviewShowFirstTitle: false,
|
||||
cardVisibleColumns: 1,
|
||||
page: 0,
|
||||
});
|
||||
|
||||
source$: Observable<string>;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ export class CoreReportBuilderListPage implements AfterViewInit, OnDestroy {
|
|||
|
||||
reports!: CoreListItemsManager<CoreReportBuilderReport, CoreReportBuilderReportsSource>;
|
||||
|
||||
state$: Readonly<BehaviorSubject<CoreReportBuilderListState>> = new BehaviorSubject({
|
||||
state$: Readonly<BehaviorSubject<CoreReportBuilderListState>> = new BehaviorSubject<CoreReportBuilderListState>({
|
||||
page: 1,
|
||||
perpage: REPORTS_LIST_LIMIT,
|
||||
loaded: false,
|
||||
|
|
|
@ -41,9 +41,7 @@ export class CoreSecondsToHMSPipe implements PipeTransform {
|
|||
* @returns Formatted seconds.
|
||||
*/
|
||||
transform(seconds: string | number, showHours: boolean = true): string {
|
||||
if (!seconds || seconds < 0) {
|
||||
seconds = 0;
|
||||
} else if (typeof seconds == 'string') {
|
||||
if (typeof seconds === 'string') {
|
||||
// Convert the value to a number.
|
||||
const numberSeconds = parseInt(seconds, 10);
|
||||
if (isNaN(numberSeconds)) {
|
||||
|
@ -52,6 +50,8 @@ export class CoreSecondsToHMSPipe implements PipeTransform {
|
|||
return seconds;
|
||||
}
|
||||
seconds = numberSeconds;
|
||||
} else if (!seconds || seconds < 0) {
|
||||
seconds = 0;
|
||||
}
|
||||
|
||||
// Don't allow decimals.
|
||||
|
|
|
@ -687,7 +687,7 @@ export class CoreDomUtilsProvider {
|
|||
const element = this.convertToElement(html);
|
||||
|
||||
// Treat elements with src (img, audio, video, ...).
|
||||
const media = Array.from(element.querySelectorAll('img, video, audio, source, track'));
|
||||
const media = Array.from(element.querySelectorAll<HTMLElement>('img, video, audio, source, track'));
|
||||
media.forEach((media: HTMLElement) => {
|
||||
const currentSrc = media.getAttribute('src');
|
||||
const newSrc = currentSrc ?
|
||||
|
|
|
@ -982,7 +982,7 @@ export class CoreTextUtilsProvider {
|
|||
* @returns Number with leading zeros.
|
||||
*/
|
||||
twoDigits(num: string | number): string {
|
||||
if (num < 10) {
|
||||
if (Number(num) < 10) {
|
||||
return '0' + num;
|
||||
} else {
|
||||
return '' + num; // Convert to string for coherence.
|
||||
|
|
Loading…
Reference in New Issue