MOBILE-4081 core: Remove most .bind() usage

main
Dani Palou 2022-10-04 15:06:14 +02:00
parent c05657342e
commit 8d0412fa68
90 changed files with 256 additions and 274 deletions

View File

@ -280,7 +280,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
loadCategoryNames: showCategories, loadCategoryNames: showCategories,
readingStrategy: this.isDirty ? CoreSitesReadingStrategy.PREFER_NETWORK : loadWatcher.getReadingStrategy(), readingStrategy: this.isDirty ? CoreSitesReadingStrategy.PREFER_NETWORK : loadWatcher.getReadingStrategy(),
}), }),
this.coursesHaveMeaningfulChanges.bind(this), (prevCourses, newCourses) => this.coursesHaveMeaningfulChanges(prevCourses, newCourses),
); );
this.hasCourses = this.allCourses.length > 0; this.hasCourses = this.allCourses.length > 0;
@ -532,7 +532,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
CoreCourses.getEnrolledCoursesByCustomFieldObservable(customFilterName, customFilterValue, { CoreCourses.getEnrolledCoursesByCustomFieldObservable(customFilterName, customFilterValue, {
readingStrategy: loadWatcher.getReadingStrategy(), readingStrategy: loadWatcher.getReadingStrategy(),
}), }),
this.customFilterCoursesHaveMeaningfulChanges.bind(this), (prevCourses, newCourses) => this.customFilterCoursesHaveMeaningfulChanges(prevCourses, newCourses),
) )
: :
await CoreCourses.getEnrolledCoursesByCustomField(customFilterName, customFilterValue); await CoreCourses.getEnrolledCoursesByCustomField(customFilterName, customFilterValue);

View File

@ -20,8 +20,7 @@ import {
CoreCourseOptionsHandler, CoreCourseOptionsHandler,
CoreCourseOptionsHandlerData, CoreCourseOptionsHandlerData,
} from '@features/course/services/course-options-delegate'; } from '@features/course/services/course-options-delegate';
import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses';
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper';
import { CoreFilepool } from '@services/filepool'; import { CoreFilepool } from '@services/filepool';
import { CoreSites } from '@services/sites'; import { CoreSites } from '@services/sites';
import { CoreWSFile } from '@services/ws'; import { CoreWSFile } from '@services/ws';
@ -83,7 +82,7 @@ export class AddonBlogCourseOptionHandlerService implements CoreCourseOptionsHan
/** /**
* @inheritdoc * @inheritdoc
*/ */
async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise<void> { async prefetch(course: CoreCourseAnyCourseData): Promise<void> {
const siteId = CoreSites.getCurrentSiteId(); const siteId = CoreSites.getCurrentSiteId();
const result = await AddonBlog.getEntries({ courseid: course.id }); const result = await AddonBlog.getEntries({ courseid: course.id });

View File

@ -111,14 +111,14 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
// Refresh data if this calendar event is synchronized automatically. // Refresh data if this calendar event is synchronized automatically.
this.syncObserver = CoreEvents.on( this.syncObserver = CoreEvents.on(
AddonCalendarSyncProvider.AUTO_SYNCED, AddonCalendarSyncProvider.AUTO_SYNCED,
this.checkSyncResult.bind(this, false), (data) => this.checkSyncResult(false, data),
this.currentSiteId, this.currentSiteId,
); );
// Refresh data if calendar events are synchronized manually but not by this page. // Refresh data if calendar events are synchronized manually but not by this page.
this.manualSyncObserver = CoreEvents.on( this.manualSyncObserver = CoreEvents.on(
AddonCalendarSyncProvider.MANUAL_SYNCED, AddonCalendarSyncProvider.MANUAL_SYNCED,
this.checkSyncResult.bind(this, true), (data) => this.checkSyncResult(true, data),
this.currentSiteId, this.currentSiteId,
); );

View File

@ -55,7 +55,7 @@ export class AddonCalendarSyncProvider extends CoreSyncBaseProvider<AddonCalenda
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
async syncAllEvents(siteId?: string, force = false): Promise<void> { async syncAllEvents(siteId?: string, force = false): Promise<void> {
await this.syncOnSites('all calendar events', this.syncAllEventsFunc.bind(this, force), siteId); await this.syncOnSites('all calendar events', (siteId) => this.syncAllEventsFunc(force, siteId), siteId);
} }
/** /**

View File

@ -21,8 +21,7 @@ import {
} from '@features/course/services/course-options-delegate'; } from '@features/course/services/course-options-delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency'; import { AddonCompetency } from '../competency';
import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses';
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper';
import { CoreFilterHelper } from '@features/filter/services/filter-helper'; import { CoreFilterHelper } from '@features/filter/services/filter-helper';
import { ContextLevel } from '@/core/constants'; import { ContextLevel } from '@/core/constants';
import { ADDON_COMPETENCY_COMPETENCIES_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_COMPETENCIES_PAGE } from '@addons/competency/competency.module';
@ -94,7 +93,7 @@ export class AddonCompetencyCourseOptionHandlerService implements CoreCourseOpti
/** /**
* @inheritdoc * @inheritdoc
*/ */
async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise<void> { async prefetch(course: CoreCourseAnyCourseData): Promise<void> {
// Get the competencies in the course. // Get the competencies in the course.
const competencies = await AddonCompetency.getCourseCompetencies(course.id, undefined, undefined, true); const competencies = await AddonCompetency.getCourseCompetencies(course.id, undefined, undefined, true);

View File

@ -19,7 +19,7 @@ import {
CoreCourseOptionsHandler, CoreCourseOptionsHandler,
CoreCourseOptionsHandlerData, CoreCourseOptionsHandlerData,
} from '@features/course/services/course-options-delegate'; } from '@features/course/services/course-options-delegate';
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper'; import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonCourseCompletion } from '../coursecompletion'; import { AddonCourseCompletion } from '../coursecompletion';
@ -77,7 +77,7 @@ export class AddonCourseCompletionCourseOptionHandlerService implements CoreCour
/** /**
* @inheritdoc * @inheritdoc
*/ */
async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise<void> { async prefetch(course: CoreCourseAnyCourseData): Promise<void> {
try { try {
await AddonCourseCompletion.getCompletion(course.id, undefined, { await AddonCourseCompletion.getCompletion(course.id, undefined, {
getFromCache: false, getFromCache: false,

View File

@ -74,7 +74,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
syncAllDiscussions(siteId?: string, onlyDeviceOffline: boolean = false): Promise<void> { syncAllDiscussions(siteId?: string, onlyDeviceOffline: boolean = false): Promise<void> {
const syncFunctionLog = 'all discussions' + (onlyDeviceOffline ? ' (Only offline)' : ''); const syncFunctionLog = 'all discussions' + (onlyDeviceOffline ? ' (Only offline)' : '');
return this.syncOnSites(syncFunctionLog, this.syncAllDiscussionsFunc.bind(this, onlyDeviceOffline), siteId); return this.syncOnSites(syncFunctionLog, (siteId) => this.syncAllDiscussionsFunc(onlyDeviceOffline, siteId), siteId);
} }
/** /**

View File

@ -108,7 +108,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllAssignments(siteId?: string, force?: boolean): Promise<void> { syncAllAssignments(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all assignments', this.syncAllAssignmentsFunc.bind(this, !!force), siteId); return this.syncOnSites('all assignments', (siteId) => this.syncAllAssignmentsFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -222,7 +222,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchAssign.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchAssign(module, courseId, siteId));
} }
/** /**

View File

@ -58,7 +58,7 @@ export class AddonModChatPrefetchHandlerService extends CoreCourseActivityPrefet
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchChat.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchChat(module, courseId, siteId));
} }
/** /**

View File

@ -59,7 +59,7 @@ export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvid
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllChoices(siteId?: string, force?: boolean): Promise<void> { syncAllChoices(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all choices', this.syncAllChoicesFunc.bind(this, !!force), siteId); return this.syncOnSites('all choices', (siteId) => this.syncAllChoicesFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -39,7 +39,7 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchChoice.bind(this, module, courseId, !!single)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchChoice(module, courseId, !!single, siteId));
} }
/** /**

View File

@ -95,7 +95,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
database: AddonModDataData; database: AddonModDataData;
title: string; title: string;
group: number; group: number;
gotoEntry: (a: number) => void; gotoEntry: (entryId: number) => void;
}; };
// Data for found records translation. // Data for found records translation.
@ -372,7 +372,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
database: this.database!, database: this.database!,
title: this.module.name, title: this.module.name,
group: this.selectedGroup, group: this.selectedGroup,
gotoEntry: this.gotoEntry.bind(this), gotoEntry: (entryId) => this.gotoEntry(entryId),
}; };
} else if (!this.search.searching) { } else if (!this.search.searching) {
// Empty and no searching. // Empty and no searching.

View File

@ -405,7 +405,7 @@ export class AddonModDataEditPage implements OnInit {
form: this.editForm, form: this.editForm,
database: this.database, database: this.database,
errors: this.errors, errors: this.errors,
onFieldInit: this.onFieldInit.bind(this), onFieldInit: (data) => this.onFieldInit(data),
}; };
let template = AddonModDataHelper.getTemplate(this.database!, AddonModDataTemplateType.ADD, this.fieldsArray); let template = AddonModDataHelper.getTemplate(this.database!, AddonModDataTemplateType.ADD, this.fieldsArray);

View File

@ -116,7 +116,7 @@ export class AddonModDataOfflineProvider {
const site = await CoreSites.getSite(siteId); const site = await CoreSites.getSite(siteId);
const entries = await site.getDb().getAllRecords<AddonModDataEntryDBRecord>(DATA_ENTRY_TABLE); const entries = await site.getDb().getAllRecords<AddonModDataEntryDBRecord>(DATA_ENTRY_TABLE);
return entries.map(this.parseRecord.bind(this)); return entries.map((entry) => this.parseRecord(entry));
} }
/** /**
@ -134,7 +134,7 @@ export class AddonModDataOfflineProvider {
'timemodified', 'timemodified',
); );
return entries.map(this.parseRecord.bind(this)); return entries.map((entry) => this.parseRecord(entry));
} }
/** /**
@ -177,7 +177,7 @@ export class AddonModDataOfflineProvider {
{ dataid: dataId, entryid: entryId }, { dataid: dataId, entryid: entryId },
); );
return entries.map(this.parseRecord.bind(this)); return entries.map((entry) => this.parseRecord(entry));
} }
/** /**

View File

@ -66,7 +66,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllDatabases(siteId?: string, force?: boolean): Promise<void> { syncAllDatabases(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all databases', this.syncAllDatabasesFunc.bind(this, !!force), siteId); return this.syncOnSites('all databases', (siteId) => this.syncAllDatabasesFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -207,7 +207,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchDatabase.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchDatabase(module, courseId, siteId));
} }
/** /**

View File

@ -65,7 +65,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllFeedbacks(siteId?: string, force?: boolean): Promise<void> { syncAllFeedbacks(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all feedbacks', this.syncAllFeedbacksFunc.bind(this, !!force), siteId); return this.syncOnSites('all feedbacks', (siteId) => this.syncAllFeedbacksFunc(!!force, siteId), siteId);
} }
/** /**
@ -213,7 +213,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
responses.sort((a, b) => a.page - b.page); responses.sort((a, b) => a.page - b.page);
const orderedData = responses.map((data) => ({ const orderedData = responses.map((data) => ({
function: this.processPage.bind(this, feedback, data, siteId, timemodified, result), function: () => this.processPage(feedback, data, siteId, timemodified, result),
blocking: true, blocking: true,
})); }));

View File

@ -114,7 +114,7 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchFeedback.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchFeedback(module, courseId, siteId));
} }
/** /**

View File

@ -238,11 +238,11 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
// Listen for discussions added. When a discussion is added, we reload the data. // Listen for discussions added. When a discussion is added, we reload the data.
this.newDiscObserver = CoreEvents.on( this.newDiscObserver = CoreEvents.on(
AddonModForumProvider.NEW_DISCUSSION_EVENT, AddonModForumProvider.NEW_DISCUSSION_EVENT,
this.eventReceived.bind(this, true), (data) => this.eventReceived(true, data),
); );
this.replyObserver = CoreEvents.on( this.replyObserver = CoreEvents.on(
AddonModForumProvider.REPLY_DISCUSSION_EVENT, AddonModForumProvider.REPLY_DISCUSSION_EVENT,
this.eventReceived.bind(this, false), (data) => this.eventReceived(false, data),
); );
this.changeDiscObserver = CoreEvents.on(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data => { this.changeDiscObserver = CoreEvents.on(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data => {
if (!this.forum) { if (!this.forum) {

View File

@ -71,7 +71,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
async syncAllForums(siteId?: string, force?: boolean): Promise<void> { async syncAllForums(siteId?: string, force?: boolean): Promise<void> {
await this.syncOnSites('all forums', this.syncAllForumsFunc.bind(this, !!force), siteId); await this.syncOnSites('all forums', (siteId) => this.syncAllForumsFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -204,7 +204,7 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchForum.bind(this, module, courseId, single)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchForum(module, courseId, !!single, siteId));
} }
/** /**

View File

@ -43,7 +43,7 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource<
onlineEntries: AddonModGlossaryEntry[] = []; onlineEntries: AddonModGlossaryEntry[] = [];
offlineEntries: AddonModGlossaryOfflineEntry[] = []; offlineEntries: AddonModGlossaryOfflineEntry[] = [];
protected fetchFunction?: (options?: AddonModGlossaryGetEntriesOptions) => AddonModGlossaryGetEntriesWSResponse; protected fetchFunction?: (options?: AddonModGlossaryGetEntriesOptions) => Promise<AddonModGlossaryGetEntriesWSResponse>;
protected fetchInvalidate?: () => Promise<void>; protected fetchInvalidate?: () => Promise<void>;
constructor(courseId: number, cmId: number, glossaryPathPrefix: string) { constructor(courseId: number, cmId: number, glossaryPathPrefix: string) {
@ -162,17 +162,18 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource<
return; return;
} }
this.fetchFunction = AddonModGlossary.getEntriesBySearch.bind( const glossaryId = this.glossary.id;
AddonModGlossary.instance,
this.glossary.id, this.fetchFunction = (options) => AddonModGlossary.getEntriesBySearch(
glossaryId,
query, query,
true, true,
'CONCEPT', 'CONCEPT',
'ASC', 'ASC',
options,
); );
this.fetchInvalidate = AddonModGlossary.invalidateEntriesBySearch.bind( this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesBySearch(
AddonModGlossary.instance, glossaryId,
this.glossary.id,
query, query,
true, true,
'CONCEPT', 'CONCEPT',
@ -210,6 +211,7 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource<
throw new Error('Can\'t switch entries mode without a glossary!'); throw new Error('Can\'t switch entries mode without a glossary!');
} }
const glossaryId = this.glossary.id;
this.fetchMode = mode; this.fetchMode = mode;
this.isSearch = false; this.isSearch = false;
this.setDirty(true); this.setDirty(true);
@ -218,16 +220,15 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource<
case 'author_all': case 'author_all':
// Browse by author. // Browse by author.
this.viewMode = 'author'; this.viewMode = 'author';
this.fetchFunction = AddonModGlossary.getEntriesByAuthor.bind( this.fetchFunction = (options) => AddonModGlossary.getEntriesByAuthor(
AddonModGlossary.instance, glossaryId,
this.glossary.id,
'ALL', 'ALL',
'LASTNAME', 'LASTNAME',
'ASC', 'ASC',
options,
); );
this.fetchInvalidate = AddonModGlossary.invalidateEntriesByAuthor.bind( this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesByAuthor(
AddonModGlossary.instance, glossaryId,
this.glossary.id,
'ALL', 'ALL',
'LASTNAME', 'LASTNAME',
'ASC', 'ASC',
@ -237,14 +238,13 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource<
case 'cat_all': case 'cat_all':
// Browse by category. // Browse by category.
this.viewMode = 'cat'; this.viewMode = 'cat';
this.fetchFunction = AddonModGlossary.getEntriesByCategory.bind( this.fetchFunction = (options) => AddonModGlossary.getEntriesByCategory(
AddonModGlossary.instance, glossaryId,
this.glossary.id,
AddonModGlossaryProvider.SHOW_ALL_CATEGORIES, AddonModGlossaryProvider.SHOW_ALL_CATEGORIES,
options,
); );
this.fetchInvalidate = AddonModGlossary.invalidateEntriesByCategory.bind( this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesByCategory(
AddonModGlossary.instance, glossaryId,
this.glossary.id,
AddonModGlossaryProvider.SHOW_ALL_CATEGORIES, AddonModGlossaryProvider.SHOW_ALL_CATEGORIES,
); );
break; break;
@ -252,15 +252,14 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource<
case 'newest_first': case 'newest_first':
// Newest first. // Newest first.
this.viewMode = 'date'; this.viewMode = 'date';
this.fetchFunction = AddonModGlossary.getEntriesByDate.bind( this.fetchFunction = (options) => AddonModGlossary.getEntriesByDate(
AddonModGlossary.instance, glossaryId,
this.glossary.id,
'CREATION', 'CREATION',
'DESC', 'DESC',
options,
); );
this.fetchInvalidate = AddonModGlossary.invalidateEntriesByDate.bind( this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesByDate(
AddonModGlossary.instance, glossaryId,
this.glossary.id,
'CREATION', 'CREATION',
'DESC', 'DESC',
); );
@ -269,15 +268,14 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource<
case 'recently_updated': case 'recently_updated':
// Recently updated. // Recently updated.
this.viewMode = 'date'; this.viewMode = 'date';
this.fetchFunction = AddonModGlossary.getEntriesByDate.bind( this.fetchFunction = (options) => AddonModGlossary.getEntriesByDate(
AddonModGlossary.instance, glossaryId,
this.glossary.id,
'UPDATE', 'UPDATE',
'DESC', 'DESC',
options,
); );
this.fetchInvalidate = AddonModGlossary.invalidateEntriesByDate.bind( this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesByDate(
AddonModGlossary.instance, glossaryId,
this.glossary.id,
'UPDATE', 'UPDATE',
'DESC', 'DESC',
); );
@ -288,14 +286,13 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource<
// Consider it is 'letter_all'. // Consider it is 'letter_all'.
this.viewMode = 'letter'; this.viewMode = 'letter';
this.fetchMode = 'letter_all'; this.fetchMode = 'letter_all';
this.fetchFunction = AddonModGlossary.getEntriesByLetter.bind( this.fetchFunction = (options) => AddonModGlossary.getEntriesByLetter(
AddonModGlossary.instance, glossaryId,
this.glossary.id,
'ALL', 'ALL',
options,
); );
this.fetchInvalidate = AddonModGlossary.invalidateEntriesByLetter.bind( this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesByLetter(
AddonModGlossary.instance, glossaryId,
this.glossary.id,
'ALL', 'ALL',
); );
break; break;

View File

@ -53,7 +53,7 @@ export class AddonModGlossarySyncProvider extends CoreCourseActivitySyncBaseProv
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllGlossaries(siteId?: string, force?: boolean): Promise<void> { syncAllGlossaries(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all glossaries', this.syncAllGlossariesFunc.bind(this, !!force), siteId); return this.syncOnSites('all glossaries', (siteId) => this.syncAllGlossariesFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -759,7 +759,7 @@ export class AddonModGlossaryProvider {
const promises: Promise<void>[] = []; const promises: Promise<void>[] = [];
if (!onlyEntriesList) { if (!onlyEntriesList) {
promises.push(this.fetchAllEntries(this.getEntriesByLetter.bind(this, glossary.id, 'ALL'), { promises.push(this.fetchAllEntries((options) => this.getEntriesByLetter(glossary.id, 'ALL', options), {
cmId: glossary.coursemodule, cmId: glossary.coursemodule,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId, siteId,
@ -993,7 +993,7 @@ export class AddonModGlossaryProvider {
// If we get here, there's no offline entry with this name, check online. // If we get here, there's no offline entry with this name, check online.
// Get entries from the cache. // Get entries from the cache.
const entries = await this.fetchAllEntries(this.getEntriesByLetter.bind(glossaryId, 'ALL'), { const entries = await this.fetchAllEntries((options) => this.getEntriesByLetter(glossaryId, 'ALL', options), {
cmId: options.cmId, cmId: options.cmId,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
siteId: options.siteId, siteId: options.siteId,

View File

@ -45,7 +45,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
const glossary = await AddonModGlossary.getGlossary(courseId, module.id); const glossary = await AddonModGlossary.getGlossary(courseId, module.id);
const entries = await AddonModGlossary.fetchAllEntries( const entries = await AddonModGlossary.fetchAllEntries(
AddonModGlossary.getEntriesByLetter.bind(AddonModGlossary.instance, glossary.id, 'ALL'), (options) => AddonModGlossary.getEntriesByLetter(glossary.id, 'ALL', options),
{ {
cmId: module.id, cmId: module.id,
}, },
@ -96,7 +96,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchGlossary.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchGlossary(module, courseId, siteId));
} }
/** /**
@ -125,42 +125,42 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
break; break;
case 'cat': case 'cat':
promises.push(AddonModGlossary.fetchAllEntries( promises.push(AddonModGlossary.fetchAllEntries(
AddonModGlossary.getEntriesByCategory.bind( (newOptions) => AddonModGlossary.getEntriesByCategory(
AddonModGlossary.instance,
glossary.id, glossary.id,
AddonModGlossaryProvider.SHOW_ALL_CATEGORIES, AddonModGlossaryProvider.SHOW_ALL_CATEGORIES,
newOptions,
), ),
options, options,
)); ));
break; break;
case 'date': case 'date':
promises.push(AddonModGlossary.fetchAllEntries( promises.push(AddonModGlossary.fetchAllEntries(
AddonModGlossary.getEntriesByDate.bind( (newOptions) => AddonModGlossary.getEntriesByDate(
AddonModGlossary.instance,
glossary.id, glossary.id,
'CREATION', 'CREATION',
'DESC', 'DESC',
newOptions,
), ),
options, options,
)); ));
promises.push(AddonModGlossary.fetchAllEntries( promises.push(AddonModGlossary.fetchAllEntries(
AddonModGlossary.getEntriesByDate.bind( (newOptions) => AddonModGlossary.getEntriesByDate(
AddonModGlossary.instance,
glossary.id, glossary.id,
'UPDATE', 'UPDATE',
'DESC', 'DESC',
newOptions,
), ),
options, options,
)); ));
break; break;
case 'author': case 'author':
promises.push(AddonModGlossary.fetchAllEntries( promises.push(AddonModGlossary.fetchAllEntries(
AddonModGlossary.getEntriesByAuthor.bind( (newOptions) => AddonModGlossary.getEntriesByAuthor(
AddonModGlossary.instance,
glossary.id, glossary.id,
'ALL', 'ALL',
'LASTNAME', 'LASTNAME',
'ASC', 'ASC',
newOptions,
), ),
options, options,
)); ));
@ -171,7 +171,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
// Fetch all entries to get information from. // Fetch all entries to get information from.
promises.push(AddonModGlossary.fetchAllEntries( promises.push(AddonModGlossary.fetchAllEntries(
AddonModGlossary.getEntriesByLetter.bind(AddonModGlossary.instance, glossary.id, 'ALL'), (newOptions) => AddonModGlossary.getEntriesByLetter(glossary.id, 'ALL', newOptions),
options, options,
).then((entries) => { ).then((entries) => {
const promises: Promise<unknown>[] = []; const promises: Promise<unknown>[] = [];

View File

@ -98,7 +98,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
this.siteCanDownload = this.site.canDownloadFiles() && !CoreH5P.isOfflineDisabledInSite(); this.siteCanDownload = this.site.canDownloadFiles() && !CoreH5P.isOfflineDisabledInSite();
// Listen for messages from the iframe. // Listen for messages from the iframe.
this.messageListenerFunction = this.onIframeMessage.bind(this); this.messageListenerFunction = (event) => this.onIframeMessage(event);
window.addEventListener('message', this.messageListenerFunction); window.addEventListener('message', this.messageListenerFunction);
} }

View File

@ -48,7 +48,7 @@ export class AddonModH5PActivitySyncProvider extends CoreCourseActivitySyncBaseP
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllActivities(siteId?: string, force?: boolean): Promise<void> { syncAllActivities(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('H5P activities', this.syncAllActivitiesFunc.bind(this, !!force), siteId); return this.syncOnSites('H5P activities', (siteId) => this.syncAllActivitiesFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -77,7 +77,7 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchActivity.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchActivity(module, courseId, siteId));
} }
/** /**

View File

@ -285,12 +285,13 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
this.offline = true; this.offline = true;
} }
const lessonId = this.lesson.id;
const options = { const options = {
cmId: this.cmId, cmId: this.cmId,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
}; };
this.accessInfo = await this.callFunction<AddonModLessonGetAccessInformationWSResponse>( this.accessInfo = await this.callFunction<AddonModLessonGetAccessInformationWSResponse>(
AddonModLesson.getAccessInformation.bind(AddonModLesson.instance, this.lesson.id, options), () => AddonModLesson.getAccessInformation(lessonId, options),
options, options,
); );
@ -321,7 +322,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
}; };
promises.push(this.callFunction<AddonModLessonLessonWSData>( promises.push(this.callFunction<AddonModLessonLessonWSData>(
AddonModLesson.getLessonWithPassword.bind(AddonModLesson.instance, this.lesson.id, options), () => AddonModLesson.getLessonWithPassword(lessonId, options),
options, options,
).then((lesson) => { ).then((lesson) => {
this.lesson = lesson; this.lesson = lesson;
@ -373,17 +374,22 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
protected async finishRetake(outOfTime?: boolean): Promise<void> { protected async finishRetake(outOfTime?: boolean): Promise<void> {
if (!this.lesson) {
return;
}
const lesson = this.lesson;
this.messages = []; this.messages = [];
if (this.offline && CoreNetwork.isOnline()) { if (this.offline && CoreNetwork.isOnline()) {
// Offline mode but the app is online. Try to sync the data. // Offline mode but the app is online. Try to sync the data.
const result = await CoreUtils.ignoreErrors( const result = await CoreUtils.ignoreErrors(
AddonModLessonSync.syncLesson(this.lesson!.id, true, true), AddonModLessonSync.syncLesson(lesson.id, true, true),
); );
if (result?.warnings?.length) { if (result?.warnings?.length) {
// Some data was deleted. Check if the retake has changed. // Some data was deleted. Check if the retake has changed.
const info = await AddonModLesson.getAccessInformation(this.lesson!.id, { const info = await AddonModLesson.getAccessInformation(lesson.id, {
cmId: this.cmId, cmId: this.cmId,
}); });
@ -411,11 +417,11 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
accessInfo: this.accessInfo, accessInfo: this.accessInfo,
}; };
const data = await this.callFunction<AddonModLessonFinishRetakeResponse>( const data = await this.callFunction<AddonModLessonFinishRetakeResponse>(
AddonModLesson.finishRetake.bind(AddonModLesson.instance, this.lesson, this.courseId, options), () => AddonModLesson.finishRetake(lesson, this.courseId, options),
options, options,
); );
this.title = this.lesson!.name; this.title = lesson.name;
this.eolData = data.data; this.eolData = data.data;
this.messages = this.messages.concat(data.messages); this.messages = this.messages.concat(data.messages);
this.processData = undefined; this.processData = undefined;
@ -512,13 +518,14 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
protected async loadMenu(): Promise<void> { protected async loadMenu(): Promise<void> {
if (this.loadingMenu) { if (this.loadingMenu || !this.lesson) {
// Already loading. // Already loading.
return; return;
} }
try { try {
this.loadingMenu = true; this.loadingMenu = true;
const lessonId = this.lesson.id;
const options = { const options = {
password: this.password, password: this.password,
cmId: this.cmId, cmId: this.cmId,
@ -526,7 +533,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
}; };
const pages = await this.callFunction<AddonModLessonGetPagesPageWSData[]>( const pages = await this.callFunction<AddonModLessonGetPagesPageWSData[]>(
AddonModLesson.getPages.bind(AddonModLesson.instance, this.lesson!.id, options), () => AddonModLesson.getPages(lessonId, options),
options, options,
); );
@ -548,8 +555,11 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
if (pageId == AddonModLessonProvider.LESSON_EOL) { if (pageId == AddonModLessonProvider.LESSON_EOL) {
// End of lesson reached. // End of lesson reached.
return this.finishRetake(); return this.finishRetake();
} else if (!this.lesson) {
return;
} }
const lesson = this.lesson;
const options = { const options = {
password: this.password, password: this.password,
review: this.review, review: this.review,
@ -562,7 +572,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
}; };
const data = await this.callFunction<AddonModLessonGetPageDataWSResponse>( const data = await this.callFunction<AddonModLessonGetPageDataWSResponse>(
AddonModLesson.getPageData.bind(AddonModLesson.instance, this.lesson, pageId, options), () => AddonModLesson.getPageData(lesson, pageId, options),
options, options,
); );
@ -615,8 +625,14 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
protected async processPage(data: CoreFormFields, formSubmitted?: boolean): Promise<void> { protected async processPage(data: CoreFormFields, formSubmitted?: boolean): Promise<void> {
if (!this.lesson || !this.pageData) {
return;
}
this.loaded = false; this.loaded = false;
const lesson = this.lesson;
const pageData = this.pageData;
const options: AddonModLessonProcessPageOptions = { const options: AddonModLessonProcessPageOptions = {
password: this.password, password: this.password,
review: this.review, review: this.review,
@ -627,11 +643,10 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
try { try {
const result = await this.callFunction<AddonModLessonProcessPageResponse>( const result = await this.callFunction<AddonModLessonProcessPageResponse>(
AddonModLesson.processPage.bind( () => AddonModLesson.processPage(
AddonModLesson.instance, lesson,
this.lesson,
this.courseId, this.courseId,
this.pageData, pageData,
data, data,
options, options,
), ),
@ -646,7 +661,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
); );
} }
if (!this.offline && !this.review && AddonModLesson.isLessonOffline(this.lesson!)) { if (!this.offline && !this.review && AddonModLesson.isLessonOffline(lesson)) {
// Lesson allows offline and the user changed some data in server. Update cached data. // Lesson allows offline and the user changed some data in server. Update cached data.
const retake = this.accessInfo!.attemptscount; const retake = this.accessInfo!.attemptscount;
const options = { const options = {
@ -656,9 +671,9 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
// Update in background the list of content pages viewed or question attempts. // Update in background the list of content pages viewed or question attempts.
if (AddonModLesson.isQuestionPage(this.pageData?.page?.type || -1)) { if (AddonModLesson.isQuestionPage(this.pageData?.page?.type || -1)) {
AddonModLesson.getQuestionsAttemptsOnline(this.lesson!.id, retake, options); AddonModLesson.getQuestionsAttemptsOnline(lesson.id, retake, options);
} else { } else {
AddonModLesson.getContentPagesViewedOnline(this.lesson!.id, retake, options); AddonModLesson.getContentPagesViewedOnline(lesson.id, retake, options);
} }
} }
@ -673,7 +688,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
this.processData = result; this.processData = result;
this.processDataButtons = []; this.processDataButtons = [];
if (this.lesson!.review && !result.correctanswer && !result.noanswer && !result.isessayquestion && if (lesson.review && !result.correctanswer && !result.noanswer && !result.isessayquestion &&
!result.maxattemptsreached && !result.reviewmode) { !result.maxattemptsreached && !result.reviewmode) {
// User can try again, show button to do so. // User can try again, show button to do so.
this.processDataButtons.push({ this.processDataButtons.push({
@ -683,11 +698,11 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
} }
// Button to continue. // Button to continue.
if (this.lesson!.review && !result.correctanswer && !result.noanswer && !result.isessayquestion && if (lesson.review && !result.correctanswer && !result.noanswer && !result.isessayquestion &&
!result.maxattemptsreached) { !result.maxattemptsreached) {
/* If both the "Yes, I'd like to try again" and "No, I just want to go on to the next question" point to the /* If both the "Yes, I'd like to try again" and "No, I just want to go on to the next question" point to the
same page then don't show the "No, I just want to go on to the next question" button. It's confusing. */ same page then don't show the "No, I just want to go on to the next question" button. It's confusing. */
if (this.pageData!.page!.id != result.newpageid) { if (pageData.page?.id != result.newpageid) {
// Button to continue the lesson (the page to go is configured by the teacher). // Button to continue the lesson (the page to go is configured by the teacher).
this.processDataButtons.push({ this.processDataButtons.push({
label: 'addon.mod_lesson.reviewquestioncontinue', label: 'addon.mod_lesson.reviewquestioncontinue',

View File

@ -225,7 +225,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchLesson.bind(this, module, courseId, !!single)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchLesson(module, courseId, !!single, siteId));
} }
/** /**

View File

@ -122,7 +122,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllLessons(siteId?: string, force = false): Promise<void> { syncAllLessons(siteId?: string, force = false): Promise<void> {
return this.syncOnSites('all lessons', this.syncAllLessonsFunc.bind(this, !!force), siteId); return this.syncOnSites('all lessons', (siteId) => this.syncAllLessonsFunc(!!force, siteId), siteId);
} }
/** /**
@ -333,7 +333,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid
attempts.sort((a, b) => a.timemodified - b.timemodified); attempts.sort((a, b) => a.timemodified - b.timemodified);
const promisesData = attempts.map((attempt) => ({ const promisesData = attempts.map((attempt) => ({
function: this.sendAttempt.bind(this, lesson, passwordData.password, attempt, result, siteId), function: () => this.sendAttempt(lesson, passwordData.password ?? '', attempt, result, siteId),
blocking: true, blocking: true,
})); }));

View File

@ -278,7 +278,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
return; return;
} }
return this.prefetchPackage(module, courseId, this.prefetchQuiz.bind(this, module, courseId, !!single, canStart)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchQuiz(module, courseId, !!single, canStart, siteId));
} }
/** /**

View File

@ -180,7 +180,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllQuizzes(siteId?: string, force?: boolean): Promise<void> { syncAllQuizzes(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all quizzes', this.syncAllQuizzesFunc.bind(this, !!force), siteId); return this.syncOnSites('all quizzes', (siteId) => this.syncAllQuizzesFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -70,7 +70,10 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
sectionId?: number, sectionId?: number,
forCoursePage?: boolean, forCoursePage?: boolean,
): Promise<CoreCourseModuleHandlerData> { ): Promise<CoreCourseModuleHandlerData> {
const updateStatus = (status: string): void => { const openWithPicker = CoreFileHelper.defaultIsOpenWithPicker();
const handlerData = await super.getData(module, courseId, sectionId, forCoursePage);
handlerData.updateStatus = (status) => {
if (!handlerData.buttons) { if (!handlerData.buttons) {
return; return;
} }
@ -78,10 +81,6 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
handlerData.buttons[0].hidden = status !== CoreConstants.DOWNLOADED || handlerData.buttons[0].hidden = status !== CoreConstants.DOWNLOADED ||
AddonModResourceHelper.isDisplayedInIframe(module); AddonModResourceHelper.isDisplayedInIframe(module);
}; };
const openWithPicker = CoreFileHelper.defaultIsOpenWithPicker();
const handlerData = await super.getData(module, courseId, sectionId, forCoursePage);
handlerData.updateStatus = updateStatus.bind(this);
handlerData.buttons = [{ handlerData.buttons = [{
hidden: true, hidden: true,
icon: openWithPicker ? 'fas-share-square' : 'fas-file', icon: openWithPicker ? 'fas-share-square' : 'fas-file',

View File

@ -883,7 +883,7 @@ export class AddonModScormDataModel12 {
// Store data. // Store data.
if (this.errorCode == '0') { if (this.errorCode == '0') {
if (this.scorm.autocommit && !this.timeout) { if (this.scorm.autocommit && !this.timeout) {
this.timeout = window.setTimeout(this.LMSCommit.bind(this), 60000, ['']); this.timeout = window.setTimeout(() => this.LMSCommit(''), 60000);
} }
const range = this.dataModel[this.scoId][elementModel].range; const range = this.dataModel[this.scoId][elementModel].range;

View File

@ -175,7 +175,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
if (this.offline) { if (this.offline) {
// Wait a bit to make sure data is stored. // Wait a bit to make sure data is stored.
setTimeout(this.refreshToc.bind(this), 100); setTimeout(() => this.refreshToc(), 100);
} else { } else {
this.refreshToc(); this.refreshToc();
} }

View File

@ -50,7 +50,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
return this.prefetchPackage( return this.prefetchPackage(
module, module,
courseId, courseId,
this.downloadOrPrefetchScorm.bind(this, module, courseId, true, false, onProgress), (siteId) => this.downloadOrPrefetchScorm(module, courseId, true, false, onProgress, siteId),
); );
} }
@ -126,7 +126,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
scorm.coursemodule, scorm.coursemodule,
undefined, undefined,
undefined, undefined,
this.downloadProgress.bind(this, true, onProgress), (event: ProgressEvent<EventTarget>) => this.downloadProgress(true, onProgress, event),
); );
} else { } else {
await CoreFilepool.downloadUrl( await CoreFilepool.downloadUrl(
@ -136,7 +136,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
this.component, this.component,
scorm.coursemodule, scorm.coursemodule,
undefined, undefined,
this.downloadProgress.bind(this, true, onProgress), (event: ProgressEvent<EventTarget>) => this.downloadProgress(true, onProgress, event),
); );
} }
@ -147,7 +147,11 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
onProgress && onProgress({ message: 'core.unzipping' }); onProgress && onProgress({ message: 'core.unzipping' });
// Unzip and delete the zip when finished. // Unzip and delete the zip when finished.
await CoreFile.unzipFile(zipPath, dirPath, this.downloadProgress.bind(this, false, onProgress)); await CoreFile.unzipFile(
zipPath,
dirPath,
(event: ProgressEvent<EventTarget>) => this.downloadProgress(false, onProgress, event),
);
await CoreUtils.ignoreErrors(CoreFilepool.removeFileByUrl(siteId, packageUrl)); await CoreUtils.ignoreErrors(CoreFilepool.removeFileByUrl(siteId, packageUrl));
} }
@ -371,7 +375,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
return this.prefetchPackage( return this.prefetchPackage(
module, module,
courseId, courseId,
this.downloadOrPrefetchScorm.bind(this, module, courseId, single, true, onProgress), (siteId) => this.downloadOrPrefetchScorm(module, courseId, !!single, true, onProgress, siteId),
); );
} }

View File

@ -445,7 +445,7 @@ export class AddonModScormSyncProvider extends CoreCourseActivitySyncBaseProvide
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllScorms(siteId?: string, force?: boolean): Promise<void> { syncAllScorms(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all SCORMs', this.syncAllScormsFunc.bind(this, !!force), siteId); return this.syncOnSites('all SCORMs', (siteId) => this.syncAllScormsFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -68,7 +68,7 @@ export class AddonModSurveyPrefetchHandlerService extends CoreCourseActivityPref
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchSurvey.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchSurvey(module, courseId, siteId));
} }
/** /**

View File

@ -60,7 +60,7 @@ export class AddonModSurveySyncProvider extends CoreCourseActivitySyncBaseProvid
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllSurveys(siteId?: string, force?: boolean): Promise<void> { syncAllSurveys(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all surveys', this.syncAllSurveysFunc.bind(this, !!force), siteId); return this.syncOnSites('all surveys', (siteId) => this.syncAllSurveysFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -140,7 +140,7 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet
return this.prefetchPackage( return this.prefetchPackage(
module, module,
courseId, courseId,
this.prefetchWiki.bind(this, module, courseId, !!single, downloadTime), (siteId) => this.prefetchWiki(module, courseId, !!single, downloadTime, siteId),
siteId, siteId,
); );
} }

View File

@ -73,7 +73,7 @@ export class AddonModWikiSyncProvider extends CoreSyncBaseProvider<AddonModWikiS
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllWikis(siteId?: string, force?: boolean): Promise<void> { syncAllWikis(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all wikis', this.syncAllWikisFunc.bind(this, !!force), siteId); return this.syncOnSites('all wikis', (siteId) => this.syncAllWikisFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -135,8 +135,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe
await this.load(); await this.load();
this.obsInvalidated = CoreEvents.on( this.obsInvalidated = CoreEvents.on(
AddonModWorkshopProvider.ASSESSMENT_INVALIDATED, AddonModWorkshopProvider.ASSESSMENT_INVALIDATED,
this.load.bind(this), () => this.load(),
CoreSites.getCurrentSiteId(), CoreSites.getCurrentSiteId(),
); );
} catch (error) { } catch (error) {

View File

@ -205,7 +205,7 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchWorkshop.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, (siteId) => this.prefetchWorkshop(module, courseId, siteId));
} }
/** /**

View File

@ -141,7 +141,7 @@ export class AddonModWorkshopOfflineProvider {
const records = await site.getDb().getRecords<AddonModWorkshopSubmissionDBRecord>(SUBMISSIONS_TABLE); const records = await site.getDb().getRecords<AddonModWorkshopSubmissionDBRecord>(SUBMISSIONS_TABLE);
return records.map(this.parseSubmissionRecord.bind(this)); return records.map((record) => this.parseSubmissionRecord(record));
} }
/** /**
@ -160,7 +160,7 @@ export class AddonModWorkshopOfflineProvider {
const records = await site.getDb().getRecords<AddonModWorkshopSubmissionDBRecord>(SUBMISSIONS_TABLE, conditions); const records = await site.getDb().getRecords<AddonModWorkshopSubmissionDBRecord>(SUBMISSIONS_TABLE, conditions);
return records.map(this.parseSubmissionRecord.bind(this)); return records.map((record) => this.parseSubmissionRecord(record));
} }
/** /**
@ -273,7 +273,7 @@ export class AddonModWorkshopOfflineProvider {
const records = await site.getDb().getRecords<AddonModWorkshopAssessmentDBRecord>(ASSESSMENTS_TABLE); const records = await site.getDb().getRecords<AddonModWorkshopAssessmentDBRecord>(ASSESSMENTS_TABLE);
return records.map(this.parseAssessmentRecord.bind(this)); return records.map((record) => this.parseAssessmentRecord(record));
} }
/** /**
@ -292,7 +292,7 @@ export class AddonModWorkshopOfflineProvider {
const records = await site.getDb().getRecords<AddonModWorkshopAssessmentDBRecord>(ASSESSMENTS_TABLE, conditions); const records = await site.getDb().getRecords<AddonModWorkshopAssessmentDBRecord>(ASSESSMENTS_TABLE, conditions);
return records.map(this.parseAssessmentRecord.bind(this)); return records.map((record) => this.parseAssessmentRecord(record));
} }
/** /**
@ -388,7 +388,7 @@ export class AddonModWorkshopOfflineProvider {
const records = await site.getDb().getRecords<AddonModWorkshopEvaluateSubmissionDBRecord>(EVALUATE_SUBMISSIONS_TABLE); const records = await site.getDb().getRecords<AddonModWorkshopEvaluateSubmissionDBRecord>(EVALUATE_SUBMISSIONS_TABLE);
return records.map(this.parseEvaluateSubmissionRecord.bind(this)); return records.map((record) => this.parseEvaluateSubmissionRecord(record));
} }
/** /**
@ -408,7 +408,7 @@ export class AddonModWorkshopOfflineProvider {
const records = const records =
await site.getDb().getRecords<AddonModWorkshopEvaluateSubmissionDBRecord>(EVALUATE_SUBMISSIONS_TABLE, conditions); await site.getDb().getRecords<AddonModWorkshopEvaluateSubmissionDBRecord>(EVALUATE_SUBMISSIONS_TABLE, conditions);
return records.map(this.parseEvaluateSubmissionRecord.bind(this)); return records.map((record) => this.parseEvaluateSubmissionRecord(record));
} }
/** /**
@ -518,7 +518,7 @@ export class AddonModWorkshopOfflineProvider {
const records = await site.getDb().getRecords<AddonModWorkshopEvaluateAssessmentDBRecord>(EVALUATE_ASSESSMENTS_TABLE); const records = await site.getDb().getRecords<AddonModWorkshopEvaluateAssessmentDBRecord>(EVALUATE_ASSESSMENTS_TABLE);
return records.map(this.parseEvaluateAssessmentRecord.bind(this)); return records.map((record) => this.parseEvaluateAssessmentRecord(record));
} }
/** /**
@ -538,7 +538,7 @@ export class AddonModWorkshopOfflineProvider {
const records = const records =
await site.getDb().getRecords<AddonModWorkshopEvaluateAssessmentDBRecord>(EVALUATE_ASSESSMENTS_TABLE, conditions); await site.getDb().getRecords<AddonModWorkshopEvaluateAssessmentDBRecord>(EVALUATE_ASSESSMENTS_TABLE, conditions);
return records.map(this.parseEvaluateAssessmentRecord.bind(this)); return records.map((record) => this.parseEvaluateAssessmentRecord(record));
} }
/** /**

View File

@ -73,7 +73,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
* @return Promise resolved when the sync is done. * @return Promise resolved when the sync is done.
*/ */
syncAllWorkshops(siteId?: string, force?: boolean): Promise<void> { syncAllWorkshops(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all workshops', this.syncAllWorkshopsFunc.bind(this, !!force), siteId); return this.syncOnSites('all workshops', (siteId) => this.syncAllWorkshopsFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -19,8 +19,7 @@ import {
CoreCourseOptionsHandler, CoreCourseOptionsHandler,
CoreCourseOptionsHandlerData, CoreCourseOptionsHandlerData,
} from '@features/course/services/course-options-delegate'; } from '@features/course/services/course-options-delegate';
import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses';
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonNotes } from '../notes'; import { AddonNotes } from '../notes';
@ -73,7 +72,7 @@ export class AddonNotesCourseOptionHandlerService implements CoreCourseOptionsHa
/** /**
* @inheritdoc * @inheritdoc
*/ */
async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise<void> { async prefetch(course: CoreCourseAnyCourseData): Promise<void> {
await AddonNotes.getNotes(course.id, undefined, true); await AddonNotes.getNotes(course.id, undefined, true);
} }

View File

@ -45,7 +45,7 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider<AddonNotesSyncR
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllNotes(siteId?: string, force?: boolean): Promise<void> { syncAllNotes(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all notes', this.syncAllNotesFunc.bind(this, !!force), siteId); return this.syncOnSites('all notes', (siteId) => this.syncAllNotesFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -183,7 +183,7 @@ export class AddonNotificationsNotificationPage implements OnInit, OnDestroy {
actions.push({ actions.push({
message: 'core.view', message: 'core.view',
icon: 'fas-eye', icon: 'fas-eye',
action: this.openInBrowser.bind(this), action: (siteId) => this.openInBrowser(siteId),
}); });
} }

View File

@ -55,8 +55,8 @@ export class AddonQbehaviourDeferredCBMHandlerService implements CoreQuestionBeh
question, question,
componentId, componentId,
siteId, siteId,
this.isCompleteResponse.bind(this), (...args) => this.isCompleteResponse(...args),
this.isSameResponse.bind(this), (...args) => this.isSameResponse(...args),
); );
} }

View File

@ -39,7 +39,7 @@ export class CoreSortedDelegate<
constructor(delegateName: string) { constructor(delegateName: string) {
super(delegateName, true); super(delegateName, true);
CoreEvents.on(CoreEvents.LOGOUT, this.clearSortedHandlers.bind(this)); CoreEvents.on(CoreEvents.LOGOUT, () => this.clearSortedHandlers());
CoreEvents.on(CoreEvents.SITE_POLICY_AGREED, (data) => { CoreEvents.on(CoreEvents.SITE_POLICY_AGREED, (data) => {
if (data.siteId === CoreSites.getCurrentSiteId()) { if (data.siteId === CoreSites.getCurrentSiteId()) {
// Clear loaded handlers when policy is agreed. The CoreDelegate class will load them again. // Clear loaded handlers when policy is agreed. The CoreDelegate class will load them again.
@ -47,7 +47,7 @@ export class CoreSortedDelegate<
} }
}); });
// Clear loaded handlers on login, there could be an invalid list loaded when user reconnects after token expired. // Clear loaded handlers on login, there could be an invalid list loaded when user reconnects after token expired.
CoreEvents.on(CoreEvents.LOGIN, this.clearSortedHandlers.bind(this)); CoreEvents.on(CoreEvents.LOGIN, () => this.clearSortedHandlers());
} }
/** /**

View File

@ -95,9 +95,9 @@ export class CoreDelegate<HandlerType extends CoreDelegateHandler> {
if (listenSiteEvents) { if (listenSiteEvents) {
// Update handlers on this cases. // Update handlers on this cases.
CoreEvents.on(CoreEvents.LOGIN, this.updateHandlers.bind(this)); CoreEvents.on(CoreEvents.LOGIN, () => this.updateHandlers());
CoreEvents.on(CoreEvents.SITE_UPDATED, this.updateHandlers.bind(this)); CoreEvents.on(CoreEvents.SITE_UPDATED, () => this.updateHandlers());
CoreEvents.on(CoreEvents.SITE_PLUGINS_LOADED, this.updateHandlers.bind(this)); CoreEvents.on(CoreEvents.SITE_PLUGINS_LOADED, () => this.updateHandlers());
CoreEvents.on(CoreEvents.SITE_POLICY_AGREED, (data) => { CoreEvents.on(CoreEvents.SITE_POLICY_AGREED, (data) => {
if (data.siteId === CoreSites.getCurrentSiteId()) { if (data.siteId === CoreSites.getCurrentSiteId()) {
this.updateHandlers(); this.updateHandlers();

View File

@ -29,8 +29,8 @@ export class CorePromisedValue<T = unknown> extends CorePromise<T> {
const promisedValue = new CorePromisedValue<T>(); const promisedValue = new CorePromisedValue<T>();
promise promise
.then(promisedValue.resolve.bind(promisedValue)) .then(value => promisedValue.resolve(value))
.catch(promisedValue.reject.bind(promisedValue)); .catch(error => promisedValue.reject(error));
return promisedValue; return promisedValue;
} }

View File

@ -994,7 +994,7 @@ export class CoreSite {
this.processRequestQueue(); this.processRequestQueue();
} else if (!this.requestQueueTimeout) { } else if (!this.requestQueueTimeout) {
this.requestQueueTimeout = window.setTimeout( this.requestQueueTimeout = window.setTimeout(
this.processRequestQueue.bind(this), () => this.processRequestQueue(),
CoreConstants.CONFIG.wsrequestqueuedelay, CoreConstants.CONFIG.wsrequestqueuedelay,
); );
} }

View File

@ -95,7 +95,7 @@ export class CoreTabsBaseComponent<T extends CoreTabBase> implements OnInit, Aft
tabAction: CoreTabsRoleTab<T>; tabAction: CoreTabsRoleTab<T>;
constructor(element: ElementRef) { constructor(element: ElementRef) {
this.backButtonFunction = this.backButtonClicked.bind(this); this.backButtonFunction = (event) => this.backButtonClicked(event);
this.tabAction = new CoreTabsRoleTab(this); this.tabAction = new CoreTabsRoleTab(this);

View File

@ -73,7 +73,7 @@ export class CoreContextMenuPopoverComponent {
this.closeMenu(item); this.closeMenu(item);
} }
item.action.emit(this.closeMenu.bind(this, item)); item.action.emit(() => this.closeMenu(item));
} else if (item.closeOnClick && (item.href || (!!item.onClosed && item.onClosed.observers.length > 0))) { } else if (item.closeOnClick && (item.href || (!!item.onClosed && item.onClosed.observers.length > 0))) {
this.closeMenu(item); this.closeMenu(item);
} }

View File

@ -103,7 +103,7 @@ export class CoreInfiniteLoadingComponent implements OnChanges {
} }
this.loadingMore = true; this.loadingMore = true;
this.action.emit(this.complete.bind(this)); this.action.emit(() => this.complete());
} }
/** /**
@ -112,7 +112,7 @@ export class CoreInfiniteLoadingComponent implements OnChanges {
complete(): void { complete(): void {
if (this.position == 'top') { if (this.position == 'top') {
// Wait a bit before allowing loading more, otherwise it could be re-triggered automatically when it shouldn't. // Wait a bit before allowing loading more, otherwise it could be re-triggered automatically when it shouldn't.
setTimeout(this.completeLoadMore.bind(this), 400); setTimeout(() => this.completeLoadMore(), 400);
} else { } else {
this.completeLoadMore(); this.completeLoadMore();
} }

View File

@ -64,7 +64,7 @@ export class CoreCollapsibleItemDirective implements OnInit, OnDestroy {
constructor(el: ElementRef<HTMLElement>) { constructor(el: ElementRef<HTMLElement>) {
this.element = el.nativeElement; this.element = el.nativeElement;
this.element.addEventListener('click', this.elementClicked.bind(this)); this.element.addEventListener('click', (event) => this.elementClicked(event));
this.uniqueId = 'collapsible-item-' + CoreUtils.getUniqueId('CoreCollapsibleItemDirective'); this.uniqueId = 'collapsible-item-' + CoreUtils.getUniqueId('CoreCollapsibleItemDirective');
this.element.id = this.uniqueId; this.element.id = this.uniqueId;
} }

View File

@ -116,7 +116,7 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncCompo
this.afterRender = new EventEmitter<void>(); this.afterRender = new EventEmitter<void>();
this.element.addEventListener('click', this.elementClicked.bind(this)); this.element.addEventListener('click', (event) => this.elementClicked(event));
this.siteId = this.siteId || CoreSites.getCurrentSiteId(); this.siteId = this.siteId || CoreSites.getCurrentSiteId();
} }

View File

@ -80,7 +80,7 @@ export class CoreSupressEventsDirective implements OnInit {
// Suppress the events. // Suppress the events.
for (const evName of events) { for (const evName of events) {
this.element.addEventListener(evName, this.stopBubble.bind(this)); this.element.addEventListener(evName, (event) => this.stopBubble(event));
} }
// Now listen to "click" events. // Now listen to "click" events.

View File

@ -44,7 +44,7 @@ export class CoreCommentsSyncProvider extends CoreSyncBaseProvider<CoreCommentsS
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllComments(siteId?: string, force?: boolean): Promise<void> { syncAllComments(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('all comments', this.syncAllCommentsFunc.bind(this, !!force), siteId); return this.syncOnSites('all comments', (siteId) => this.syncAllCommentsFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -179,7 +179,7 @@ export class CoreContentLinksDelegateService {
for (const name in this.handlers) { for (const name in this.handlers) {
const handler = this.handlers[name]; const handler = this.handlers[name];
const checkAll = handler.checkAllUsers; const checkAll = handler.checkAllUsers;
const isEnabledFn = this.isHandlerEnabled.bind(this, handler, relativeUrl, params, courseId); const isEnabledFn = (siteId: string) => this.isHandlerEnabled(handler, relativeUrl, params, courseId, siteId);
if (!handler.handles(relativeUrl)) { if (!handler.handles(relativeUrl)) {
// Invalid handler or it doesn't handle the URL. Stop. // Invalid handler or it doesn't handle the URL. Stop.
@ -282,7 +282,7 @@ export class CoreContentLinksDelegateService {
handler: CoreContentLinksHandler, handler: CoreContentLinksHandler,
url: string, url: string,
params: Record<string, string>, params: Record<string, string>,
courseId: number, courseId: number | undefined,
siteId: string, siteId: string,
): Promise<boolean> { ): Promise<boolean> {

View File

@ -65,21 +65,18 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
* Prefetch the module, setting package status at start and finish. * Prefetch the module, setting package status at start and finish.
* *
* Example usage from a child instance: * Example usage from a child instance:
* return this.prefetchPackage(module, courseId, single, this.prefetchModule.bind(this, otherParam), siteId); * return this.prefetchPackage(module, courseId, (siteId) => this.prefetchModule(module, otherParam, siteId), siteId);
*
* Then the function "prefetchModule" will receive params:
* prefetchModule(module, courseId, single, siteId, someParam, anotherParam)
* *
* @param module Module. * @param module Module.
* @param courseId Course ID the module belongs to. * @param courseId Course ID the module belongs to.
* @param downloadFn Function to perform the prefetch. Please check the documentation of prefetchFunction. * @param downloadFn Function to perform the prefetch. It can return a string to be stored as the package "extra" data.
* @param siteId Site ID. If not defined, current site. * @param siteId Site ID. If not defined, current site.
* @return Promise resolved when the module has been downloaded. Data returned is not reliable. * @return Promise resolved when the module has been downloaded. Data returned is not reliable.
*/ */
async prefetchPackage( async prefetchPackage(
module: CoreCourseAnyModuleData, module: CoreCourseAnyModuleData,
courseId: number, courseId: number,
downloadFunction: (siteId: string) => Promise<string>, downloadFunction: (siteId: string) => Promise<string | void>,
siteId?: string, siteId?: string,
): Promise<void> { ): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId(); siteId = siteId || CoreSites.getCurrentSiteId();
@ -104,14 +101,14 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
* *
* @param module Module. * @param module Module.
* @param courseId Course ID the module belongs to. * @param courseId Course ID the module belongs to.
* @param downloadFn Function to perform the prefetch. Please check the documentation of prefetchFunction. * @param downloadFn Function to perform the prefetch. It can return a string to be stored as the package "extra" data.
* @param siteId Site ID. If not defined, current site. * @param siteId Site ID. If not defined, current site.
* @return Promise resolved when the module has been downloaded. Data returned is not reliable. * @return Promise resolved when the module has been downloaded. Data returned is not reliable.
*/ */
protected async changeStatusAndPrefetch( protected async changeStatusAndPrefetch(
module: CoreCourseAnyModuleData, module: CoreCourseAnyModuleData,
courseId: number | undefined, courseId: number | undefined,
downloadFunction: (siteId: string) => Promise<string>, downloadFunction: (siteId: string) => Promise<string | void>,
siteId: string, siteId: string,
): Promise<void> { ): Promise<void> {
try { try {

View File

@ -90,7 +90,7 @@ export interface CoreCourseOptionsHandler extends CoreDelegateHandler {
* @param course The course. * @param course The course.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
prefetch?(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise<void>; prefetch?(course: CoreCourseAnyCourseData): Promise<void>;
} }
/** /**
@ -452,7 +452,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
handlersToDisplay.push({ handlersToDisplay.push({
data: data, data: data,
priority: handler.priority || 0, priority: handler.priority || 0,
prefetch: handler.prefetch && handler.prefetch.bind(handler), prefetch: async (course) => await handler.prefetch?.(course),
name: handler.name, name: handler.name,
}); });

View File

@ -61,7 +61,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
* Initialize. * Initialize.
*/ */
initialize(): void { initialize(): void {
CoreEvents.on(CoreEvents.LOGOUT, this.clearStatusCache.bind(this)); CoreEvents.on(CoreEvents.LOGOUT, () => this.clearStatusCache());
CoreEvents.on(CoreEvents.PACKAGE_STATUS_CHANGED, (data) => { CoreEvents.on(CoreEvents.PACKAGE_STATUS_CHANGED, (data) => {
this.updateStatusCache(data.status, data.component, data.componentId); this.updateStatusCache(data.status, data.component, data.componentId);

View File

@ -51,7 +51,7 @@ export class CoreCourseSyncProvider extends CoreSyncBaseProvider<CoreCourseSyncR
* @return Promise resolved if sync is successful, rejected if sync fails. * @return Promise resolved if sync is successful, rejected if sync fails.
*/ */
syncAllCourses(siteId?: string, force?: boolean): Promise<void> { syncAllCourses(siteId?: string, force?: boolean): Promise<void> {
return this.syncOnSites('courses', this.syncAllCoursesFunc.bind(this, !!force), siteId); return this.syncOnSites('courses', (siteId) => this.syncAllCoursesFunc(!!force, siteId), siteId);
} }
/** /**

View File

@ -171,11 +171,11 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
this.setContent(this.control?.value); this.setContent(this.control?.value);
this.originalContent = this.control?.value; this.originalContent = this.control?.value;
this.lastDraft = this.control?.value; this.lastDraft = this.control?.value;
this.editorElement.onchange = this.onChange.bind(this); this.editorElement.onchange = () => this.onChange();
this.editorElement.onkeyup = this.onChange.bind(this); this.editorElement.onkeyup = () => this.onChange();
this.editorElement.onpaste = this.onChange.bind(this); this.editorElement.onpaste = () => this.onChange();
this.editorElement.oninput = this.onChange.bind(this); this.editorElement.oninput = () => this.onChange();
this.editorElement.onkeydown = this.moveCursor.bind(this); this.editorElement.onkeydown = event => this.moveCursor(event);
// Use paragraph on enter. // Use paragraph on enter.
document.execCommand('DefaultParagraphSeparator', false, 'p'); document.execCommand('DefaultParagraphSeparator', false, 'p');
@ -258,7 +258,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
this.windowResized(); this.windowResized();
}, 50); }, 50);
document.addEventListener('selectionchange', this.selectionChangeFunction = this.updateToolbarStyles.bind(this)); document.addEventListener('selectionchange', this.selectionChangeFunction = () => this.updateToolbarStyles());
this.keyboardObserver = CoreEvents.on(CoreEvents.KEYBOARD_CHANGE, () => { this.keyboardObserver = CoreEvents.on(CoreEvents.KEYBOARD_CHANGE, () => {
// Opening or closing the keyboard also calls the resize function, but sometimes the resize is called too soon. // Opening or closing the keyboard also calls the resize function, but sometimes the resize is called too soon.

View File

@ -47,8 +47,8 @@ export class GeolocationMock extends Geolocation {
watchPosition(options?: GeolocationOptions): Observable<Geoposition> { watchPosition(options?: GeolocationOptions): Observable<Geoposition> {
return new Observable<Geoposition>((subscriber: Subscriber<Geoposition>): TeardownLogic => { return new Observable<Geoposition>((subscriber: Subscriber<Geoposition>): TeardownLogic => {
const watchId = navigator.geolocation.watchPosition( const watchId = navigator.geolocation.watchPosition(
subscriber.next.bind(subscriber), position => subscriber.next(<Geoposition> <unknown> position),
subscriber.error.bind(subscriber), error => subscriber.error(error),
options, options,
); );

View File

@ -145,7 +145,7 @@ export class CoreFileUploaderDelegateService extends CoreDelegate<CoreFileUpload
constructor() { constructor() {
super('CoreFileUploaderDelegate', true); super('CoreFileUploaderDelegate', true);
CoreEvents.on(CoreEvents.LOGOUT, this.clearSiteHandlers.bind(this)); CoreEvents.on(CoreEvents.LOGOUT, () => this.clearSiteHandlers());
} }
/** /**

View File

@ -218,6 +218,7 @@ export class CoreFilterHelperProvider {
return CoreFilterDelegate.getEnabledFilters(contextLevel, instanceId); return CoreFilterDelegate.getEnabledFilters(contextLevel, instanceId);
} }
const courseId = options.courseId;
let hasFilters = true; let hasFilters = true;
if (contextLevel == 'system' || (contextLevel == 'course' && instanceId == site.getSiteHomeId())) { if (contextLevel == 'system' || (contextLevel == 'course' && instanceId == site.getSiteHomeId())) {
@ -233,20 +234,20 @@ export class CoreFilterHelperProvider {
options.filter = true; options.filter = true;
if (contextLevel == 'module' && options.courseId) { if (contextLevel == 'module' && courseId) {
// Get all the modules filters with a single call to decrease the number of WS calls. // Get all the modules filters with a single call to decrease the number of WS calls.
const getFilters = this.getCourseModulesContexts.bind(this, options.courseId, siteId); const getFilters = () => this.getCourseModulesContexts(courseId, siteId);
return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site);
} else if (contextLevel == 'course') { } else if (contextLevel == 'course') {
// If enrolled, get all enrolled courses filters with a single call to decrease number of WS calls. // If enrolled, get all enrolled courses filters with a single call to decrease number of WS calls.
const getFilters = this.getCourseContexts.bind(this, instanceId, siteId); const getFilters = () => this.getCourseContexts(instanceId, siteId);
return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site);
} else if (contextLevel == 'block' && options.courseId && CoreCourse.canGetCourseBlocks(site)) { } else if (contextLevel == 'block' && courseId && CoreCourse.canGetCourseBlocks(site)) {
// Get all the course blocks filters with a single call to decrease number of WS calls. // Get all the course blocks filters with a single call to decrease number of WS calls.
const getFilters = this.getBlocksContexts.bind(this, options.courseId, siteId); const getFilters = () => this.getBlocksContexts(courseId, siteId);
return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site);
} }

View File

@ -19,8 +19,7 @@ import {
CoreCourseOptionsHandler, CoreCourseOptionsHandler,
CoreCourseOptionsHandlerData, CoreCourseOptionsHandlerData,
} from '@features/course/services/course-options-delegate'; } from '@features/course/services/course-options-delegate';
import { CoreCourses, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { CoreCourseAnyCourseData, CoreCourses, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses';
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { CoreGrades } from '../grades'; import { CoreGrades } from '../grades';
@ -34,11 +33,7 @@ export class CoreGradesCourseOptionHandlerService implements CoreCourseOptionsHa
priority = 400; priority = 400;
/** /**
* Should invalidate the data to determine if the handler is enabled for a certain course. * @inheritdoc
*
* @param courseId The course ID.
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
* @return Promise resolved when done.
*/ */
invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> { invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> {
if (navOptions && navOptions.grades !== undefined) { if (navOptions && navOptions.grades !== undefined) {
@ -50,21 +45,14 @@ export class CoreGradesCourseOptionHandlerService implements CoreCourseOptionsHa
} }
/** /**
* Check if the handler is enabled on a site level. * @inheritdoc
*
* @return Whether or not the handler is enabled on a site level.
*/ */
async isEnabled(): Promise<boolean> { async isEnabled(): Promise<boolean> {
return true; return true;
} }
/** /**
* Whether or not the handler is enabled for a certain course. * @inheritdoc
*
* @param courseId The course ID.
* @param accessData Access type and data. Default, guest, ...
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
* @return True or promise resolved with true if enabled.
*/ */
isEnabledForCourse( isEnabledForCourse(
courseId: number, courseId: number,
@ -94,12 +82,9 @@ export class CoreGradesCourseOptionHandlerService implements CoreCourseOptionsHa
} }
/** /**
* Called when a course is downloaded. It should prefetch all the data to be able to see the addon in offline. * @inheritdoc
*
* @param course The course.
* @return Promise resolved when done.
*/ */
async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise<void> { async prefetch(course: CoreCourseAnyCourseData): Promise<void> {
try { try {
await CoreGrades.getCourseGradesTable(course.id, undefined, undefined, true); await CoreGrades.getCourseGradesTable(course.id, undefined, undefined, true);
} catch (error) { } catch (error) {

View File

@ -92,7 +92,7 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
tabAction: CoreMainMenuRoleTab; tabAction: CoreMainMenuRoleTab;
constructor() { constructor() {
this.backButtonFunction = this.backButtonClicked.bind(this); this.backButtonFunction = (event) => this.backButtonClicked(event);
this.tabAction = new CoreMainMenuRoleTab(this); this.tabAction = new CoreMainMenuRoleTab(this);
this.logger = CoreLogger.getInstance('CoreMainMenuPage'); this.logger = CoreLogger.getInstance('CoreMainMenuPage');

View File

@ -50,7 +50,7 @@ export class CoreMainMenuMorePage implements OnInit, OnDestroy {
protected resizeListener?: CoreEventObserver; protected resizeListener?: CoreEventObserver;
constructor() { constructor() {
this.langObserver = CoreEvents.on(CoreEvents.LANGUAGE_CHANGED, this.loadCustomMenuItems.bind(this)); this.langObserver = CoreEvents.on(CoreEvents.LANGUAGE_CHANGED, () => this.loadCustomMenuItems());
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, async () => { this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, async () => {
this.customItems = await CoreMainMenu.getCustomMenuItems(); this.customItems = await CoreMainMenu.getCustomMenuItems();

View File

@ -84,9 +84,9 @@ export class CoreSettingsHelperProvider {
} }
}; };
CoreEvents.on(CoreEvents.LOGIN, applySiteScheme.bind(this)); CoreEvents.on(CoreEvents.LOGIN, () => applySiteScheme());
CoreEvents.on(CoreEvents.SITE_UPDATED, applySiteScheme.bind(this)); CoreEvents.on(CoreEvents.SITE_UPDATED, () => applySiteScheme());
CoreEvents.on(CoreEvents.LOGOUT, () => { CoreEvents.on(CoreEvents.LOGOUT, () => {
// Reset color scheme settings. // Reset color scheme settings.

View File

@ -19,8 +19,7 @@ import {
CoreCourseOptionsHandlerData, CoreCourseOptionsHandlerData,
CoreCourseOptionsMenuHandlerData, CoreCourseOptionsMenuHandlerData,
} from '@features/course/services/course-options-delegate'; } from '@features/course/services/course-options-delegate';
import { CoreCourseAnyCourseDataWithOptions } from '@features/courses/services/courses'; import { CoreCourseAnyCourseData, CoreCourseAnyCourseDataWithOptions } from '@features/courses/services/courses';
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper';
import { import {
CoreSitePlugins, CoreSitePlugins,
CoreSitePluginsContent, CoreSitePluginsContent,
@ -107,7 +106,7 @@ export class CoreSitePluginsCourseOptionHandler extends CoreSitePluginsBaseHandl
/** /**
* @inheritdoc * @inheritdoc
*/ */
prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise<void> { prefetch(course: CoreCourseAnyCourseData): Promise<void> {
const args = { const args = {
courseid: course.id, courseid: course.id,
}; };

View File

@ -56,7 +56,7 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp
if (initResult?.jsResult && initResult.jsResult.supportsFeature) { if (initResult?.jsResult && initResult.jsResult.supportsFeature) {
// The init result defines a function to check if a feature is supported, use it. // The init result defines a function to check if a feature is supported, use it.
this.supportsFeature = initResult.jsResult.supportsFeature.bind(initResult.jsResult); this.supportsFeature = (feature) => initResult.jsResult.supportsFeature(feature);
} }
} }

View File

@ -58,7 +58,7 @@ export class CoreSitePluginsModulePrefetchHandler extends CoreCourseActivityPref
return this.prefetchPackage( return this.prefetchPackage(
module, module,
courseId, courseId,
this.downloadPrefetchPlugin.bind(this, module, courseId, false, dirPath, siteId), (siteId) => this.downloadPrefetchPlugin(module, courseId, false, dirPath, siteId),
siteId, siteId,
); );
} }
@ -226,7 +226,7 @@ export class CoreSitePluginsModulePrefetchHandler extends CoreCourseActivityPref
return this.prefetchPackage( return this.prefetchPackage(
module, module,
courseId, courseId,
this.downloadPrefetchPlugin.bind(this, module, courseId, true, dirPath), (siteId) => this.downloadPrefetchPlugin(module, courseId, true, dirPath, siteId),
); );
} }

View File

@ -108,11 +108,13 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck {
this.jsData = Object.assign(this.data, CoreSitePlugins.createDataForJS(this.initResult, result)); this.jsData = Object.assign(this.data, CoreSitePlugins.createDataForJS(this.initResult, result));
// Pass some methods as jsData so they can be called from the template too. // Pass some methods as jsData so they can be called from the template too.
this.jsData.fetchContent = this.fetchContent.bind(this); this.jsData.fetchContent = refresh => this.fetchContent(refresh);
this.jsData.openContent = this.openContent.bind(this); this.jsData.openContent = (title, args, component, method, jsData, preSets, ptrEnabled) =>
this.jsData.refreshContent = this.refreshContent.bind(this); this.openContent(title, args, component, method, jsData, preSets, ptrEnabled);
this.jsData.updateContent = this.updateContent.bind(this); this.jsData.refreshContent = showSpinner => this.refreshContent(showSpinner);
this.jsData.updateModuleCourseContent = this.updateModuleCourseContent.bind(this); this.jsData.updateContent = (args, component, method, jsData, preSets) =>
this.updateContent(args, component, method, jsData, preSets);
this.jsData.updateModuleCourseContent = (cmId, alreadyFetched) => this.updateModuleCourseContent(cmId, alreadyFetched);
this.onContentLoaded.emit({ refresh: !!refresh, success: true }); this.onContentLoaded.emit({ refresh: !!refresh, success: true });
} catch (error) { } catch (error) {

View File

@ -362,7 +362,7 @@ export class CoreSitePluginsHelperProvider {
plugin.parsedHandlers = CoreTextUtils.parseJSON( plugin.parsedHandlers = CoreTextUtils.parseJSON(
plugin.handlers, plugin.handlers,
null, null,
this.logger.error.bind(this.logger, 'Error parsing site plugin handlers'), error => this.logger.error('Error parsing site plugin handlers', error),
); );
} }
@ -370,7 +370,7 @@ export class CoreSitePluginsHelperProvider {
plugin.parsedLang = CoreTextUtils.parseJSON( plugin.parsedLang = CoreTextUtils.parseJSON(
plugin.lang, plugin.lang,
null, null,
this.logger.error.bind(this.logger, 'Error parsing site plugin lang'), error => this.logger.error('Error parsing site plugin lang', error),
); );
} }

View File

@ -468,7 +468,7 @@ export class CoreSitePluginsProvider {
plugin.parsedHandlers = CoreTextUtils.parseJSON( plugin.parsedHandlers = CoreTextUtils.parseJSON(
plugin.handlers, plugin.handlers,
null, null,
this.logger.error.bind(this.logger, 'Error parsing site plugin handlers'), error => this.logger.error('Error parsing site plugin handlers', error),
); );
} }

View File

@ -19,8 +19,7 @@ import {
CoreCourseOptionsHandler, CoreCourseOptionsHandler,
CoreCourseOptionsHandlerData, CoreCourseOptionsHandlerData,
} from '@features/course/services/course-options-delegate'; } from '@features/course/services/course-options-delegate';
import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses';
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper';
import { PARTICIPANTS_PAGE_NAME } from '@features/user/user.module'; import { PARTICIPANTS_PAGE_NAME } from '@features/user/user.module';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { CoreUser } from '../user'; import { CoreUser } from '../user';
@ -35,11 +34,7 @@ export class CoreUserCourseOptionHandlerService implements CoreCourseOptionsHand
priority = 600; priority = 600;
/** /**
* Should invalidate the data to determine if the handler is enabled for a certain course. * @inheritdoc
*
* @param courseId The course ID.
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
* @return Promise resolved when done.
*/ */
invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> { invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> {
if (navOptions && navOptions.participants !== undefined) { if (navOptions && navOptions.participants !== undefined) {
@ -51,21 +46,14 @@ export class CoreUserCourseOptionHandlerService implements CoreCourseOptionsHand
} }
/** /**
* Check if the handler is enabled on a site level. * @inheritdoc
*
* @return Whether or not the handler is enabled on a site level.
*/ */
isEnabled(): Promise<boolean> { isEnabled(): Promise<boolean> {
return Promise.resolve(true); return Promise.resolve(true);
} }
/** /**
* Whether or not the handler is enabled for a certain course. * @inheritdoc
*
* @param courseId The course ID.
* @param accessData Access type and data. Default, guest, ...
* @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
* @return True or promise resolved with true if enabled.
*/ */
isEnabledForCourse( isEnabledForCourse(
courseId: number, courseId: number,
@ -95,12 +83,9 @@ export class CoreUserCourseOptionHandlerService implements CoreCourseOptionsHand
} }
/** /**
* Called when a course is downloaded. It should prefetch all the data to be able to see the addon in offline. * @inheritdoc
*
* @param course The course.
* @return Promise resolved when done.
*/ */
async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise<void> { async prefetch(course: CoreCourseAnyCourseData): Promise<void> {
let offset = 0; let offset = 0;
let canLoadMore = true; let canLoadMore = true;

View File

@ -41,7 +41,7 @@ export class CoreUserSyncProvider extends CoreSyncBaseProvider<string[]> {
* @return Promise resolved with warnings if sync is successful, rejected if sync fails. * @return Promise resolved with warnings if sync is successful, rejected if sync fails.
*/ */
syncPreferences(siteId?: string): Promise<void> { syncPreferences(siteId?: string): Promise<void> {
return this.syncOnSites('all user preferences', this.syncSitePreferences.bind(this), siteId); return this.syncOnSites('all user preferences', (siteId) => this.syncSitePreferences(siteId), siteId);
} }
/** /**

View File

@ -834,9 +834,9 @@ export class CoreFileProvider {
return this.copyOrMoveExternalFile(from, to, copy); return this.copyOrMoveExternalFile(from, to, copy);
} }
const moveCopyFn: MoveCopyFunction = copy ? const moveCopyFn: MoveCopyFunction = (...args) => copy ?
(isDir ? File.copyDir.bind(File.instance) : File.copyFile.bind(File.instance)) : (isDir ? File.copyDir(...args) : File.copyFile(...args)) :
(isDir ? File.moveDir.bind(File.instance) : File.moveFile.bind(File.instance)); (isDir ? File.moveDir(...args) : File.moveFile(...args));
await this.init(); await this.init();
@ -854,14 +854,16 @@ export class CoreFileProvider {
try { try {
const entry = await moveCopyFn(this.basePath, from, this.basePath, to); const entry = await moveCopyFn(this.basePath, from, this.basePath, to);
return entry; return <FileEntry | DirectoryEntry> entry;
} catch (error) { } catch (error) {
// The copy can fail if the path has encoded characters. Try again if that's the case. // The copy can fail if the path has encoded characters. Try again if that's the case.
const decodedFrom = decodeURI(from); const decodedFrom = decodeURI(from);
const decodedTo = decodeURI(to); const decodedTo = decodeURI(to);
if (from != decodedFrom || to != decodedTo) { if (from != decodedFrom || to != decodedTo) {
return moveCopyFn(this.basePath, decodedFrom, this.basePath, decodedTo); const entry = await moveCopyFn(this.basePath, decodedFrom, this.basePath, decodedTo);
return <FileEntry | DirectoryEntry> entry;
} else { } else {
return Promise.reject(error); return Promise.reject(error);
} }
@ -1307,4 +1309,4 @@ export class CoreFileProvider {
export const CoreFile = makeSingleton(CoreFileProvider); export const CoreFile = makeSingleton(CoreFileProvider);
type MoveCopyFunction = (path: string, dirName: string, newPath: string, newDirName: string) => Promise<FileEntry | DirectoryEntry>; type MoveCopyFunction = (path: string, name: string, newPath: string, newName: string) => Promise<Entry>;

View File

@ -293,7 +293,7 @@ export class CoreLangProvider {
* @return Translated month names. * @return Translated month names.
*/ */
getMonthNames(): string[] { getMonthNames(): string[] {
return moment.months().map(this.capitalize.bind(this)); return moment.months().map(month => this.capitalize(month));
} }
/** /**
@ -302,7 +302,7 @@ export class CoreLangProvider {
* @return Translated month short names. * @return Translated month short names.
*/ */
getMonthShortNames(): string[] { getMonthShortNames(): string[] {
return moment.monthsShort().map(this.capitalize.bind(this)); return moment.monthsShort().map(month => this.capitalize(month));
} }
/** /**
@ -311,7 +311,7 @@ export class CoreLangProvider {
* @return Translated day names. * @return Translated day names.
*/ */
getDayNames(): string[] { getDayNames(): string[] {
return moment.weekdays().map(this.capitalize.bind(this)); return moment.weekdays().map(weekDay => this.capitalize(weekDay));
} }
/** /**
@ -320,7 +320,7 @@ export class CoreLangProvider {
* @return Translated day short names. * @return Translated day short names.
*/ */
getDayShortNames(): string[] { getDayShortNames(): string[] {
return moment.weekdaysShort().map(this.capitalize.bind(this)); return moment.weekdaysShort().map(weekDay => this.capitalize(weekDay));
} }
/** /**

View File

@ -74,7 +74,7 @@ export class CoreScreenService {
}), {} as Record<Breakpoint, boolean>)); }), {} as Record<Breakpoint, boolean>));
this._layoutObservable = this.breakpointsObservable.pipe( this._layoutObservable = this.breakpointsObservable.pipe(
map(this.calculateLayout.bind(this)), map(breakpoints => this.calculateLayout(breakpoints)),
distinctUntilChanged<CoreScreenLayout>(), distinctUntilChanged<CoreScreenLayout>(),
); );
} }

View File

@ -398,7 +398,7 @@ export class CoreIframeUtilsProvider {
// Add click listener to the link, this way if the iframe has added a listener to the link it will be executed first. // Add click listener to the link, this way if the iframe has added a listener to the link it will be executed first.
link.treated = true; link.treated = true;
link.addEventListener('click', this.linkClicked.bind(this, link, element)); link.addEventListener('click', event => this.linkClicked(link, element, event));
}, { }, {
capture: true, // Use capture to fix this listener not called if the element clicked is too deep in the DOM. capture: true, // Use capture to fix this listener not called if the element clicked is too deep in the DOM.
}); });
@ -468,7 +468,7 @@ export class CoreIframeUtilsProvider {
*/ */
protected async linkClicked( protected async linkClicked(
link: CoreIframeHTMLAnchorElement | {href: string; target?: string; originalHref?: string}, link: CoreIframeHTMLAnchorElement | {href: string; target?: string; originalHref?: string},
element?: HTMLFrameElement | HTMLObjectElement, element?: CoreFrameElement,
event?: Event, event?: Event,
): Promise<void> { ): Promise<void> {
if (event && event.defaultPrevented) { if (event && event.defaultPrevented) {
@ -554,7 +554,7 @@ export class CoreIframeUtilsProvider {
userScriptWindow.WKUserScript?.addScript({ id: 'CoreIframeUtilsLinksScript', file: linksPath }); userScriptWindow.WKUserScript?.addScript({ id: 'CoreIframeUtilsLinksScript', file: linksPath });
// Handle post messages received by iframes. // Handle post messages received by iframes.
window.addEventListener('message', this.handleIframeMessage.bind(this)); window.addEventListener('message', (event) => this.handleIframeMessage(event));
} }
/** /**

View File

@ -488,7 +488,7 @@ export class CoreUtilsProvider {
*/ */
async filterEnabledSites<P extends unknown[]>( async filterEnabledSites<P extends unknown[]>(
siteIds: string[], siteIds: string[],
isEnabledFn: (siteId, ...args: P) => boolean | Promise<boolean>, isEnabledFn: (siteId: string, ...args: P) => boolean | Promise<boolean>,
checkAll?: boolean, checkAll?: boolean,
...args: P ...args: P
): Promise<string[]> { ): Promise<string[]> {

View File

@ -908,7 +908,7 @@ export class CoreWSProvider {
const data = CoreTextUtils.parseJSON<any>( const data = CoreTextUtils.parseJSON<any>(
success.response, success.response,
null, null,
this.logger.error.bind(this.logger, 'Error parsing response from upload', success.response), error => this.logger.error('Error parsing response from upload', success.response, error),
); );
if (data === null) { if (data === null) {

View File

@ -86,15 +86,15 @@ export class CoreLogger {
return new CoreLogger( return new CoreLogger(
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
CoreLogger.prepareLogFn(console.log.bind(console), className), CoreLogger.prepareLogFn((...data) => console.log(...data), className),
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
CoreLogger.prepareLogFn(console.info.bind(console), className), CoreLogger.prepareLogFn((...data) => console.info(...data), className),
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
CoreLogger.prepareLogFn(console.warn.bind(console), className), CoreLogger.prepareLogFn((...data) => console.warn(...data), className),
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
CoreLogger.prepareLogFn(console.debug.bind(console), className), CoreLogger.prepareLogFn((...data) => console.debug(...data), className),
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
CoreLogger.prepareLogFn(console.error.bind(console), className), CoreLogger.prepareLogFn((...data) => console.error(...data), className),
); );
} }