diff --git a/src/addons/block/myoverview/components/myoverview/myoverview.ts b/src/addons/block/myoverview/components/myoverview/myoverview.ts index 0a6a6d6ce..3f9ff1f7b 100644 --- a/src/addons/block/myoverview/components/myoverview/myoverview.ts +++ b/src/addons/block/myoverview/components/myoverview/myoverview.ts @@ -280,7 +280,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem loadCategoryNames: showCategories, readingStrategy: this.isDirty ? CoreSitesReadingStrategy.PREFER_NETWORK : loadWatcher.getReadingStrategy(), }), - this.coursesHaveMeaningfulChanges.bind(this), + (prevCourses, newCourses) => this.coursesHaveMeaningfulChanges(prevCourses, newCourses), ); this.hasCourses = this.allCourses.length > 0; @@ -532,7 +532,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem CoreCourses.getEnrolledCoursesByCustomFieldObservable(customFilterName, customFilterValue, { readingStrategy: loadWatcher.getReadingStrategy(), }), - this.customFilterCoursesHaveMeaningfulChanges.bind(this), + (prevCourses, newCourses) => this.customFilterCoursesHaveMeaningfulChanges(prevCourses, newCourses), ) : await CoreCourses.getEnrolledCoursesByCustomField(customFilterName, customFilterValue); diff --git a/src/addons/blog/services/handlers/course-option.ts b/src/addons/blog/services/handlers/course-option.ts index c935a221d..e9bf4fe7e 100644 --- a/src/addons/blog/services/handlers/course-option.ts +++ b/src/addons/blog/services/handlers/course-option.ts @@ -20,8 +20,7 @@ import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData, } from '@features/course/services/course-options-delegate'; -import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; -import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper'; +import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { CoreFilepool } from '@services/filepool'; import { CoreSites } from '@services/sites'; import { CoreWSFile } from '@services/ws'; @@ -83,7 +82,7 @@ export class AddonBlogCourseOptionHandlerService implements CoreCourseOptionsHan /** * @inheritdoc */ - async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise { + async prefetch(course: CoreCourseAnyCourseData): Promise { const siteId = CoreSites.getCurrentSiteId(); const result = await AddonBlog.getEntries({ courseid: course.id }); diff --git a/src/addons/calendar/pages/event/event.page.ts b/src/addons/calendar/pages/event/event.page.ts index 362c4332e..101c8eb90 100644 --- a/src/addons/calendar/pages/event/event.page.ts +++ b/src/addons/calendar/pages/event/event.page.ts @@ -111,14 +111,14 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { // Refresh data if this calendar event is synchronized automatically. this.syncObserver = CoreEvents.on( AddonCalendarSyncProvider.AUTO_SYNCED, - this.checkSyncResult.bind(this, false), + (data) => this.checkSyncResult(false, data), this.currentSiteId, ); // Refresh data if calendar events are synchronized manually but not by this page. this.manualSyncObserver = CoreEvents.on( AddonCalendarSyncProvider.MANUAL_SYNCED, - this.checkSyncResult.bind(this, true), + (data) => this.checkSyncResult(true, data), this.currentSiteId, ); diff --git a/src/addons/calendar/services/calendar-sync.ts b/src/addons/calendar/services/calendar-sync.ts index 47c78cbcd..c2a351e87 100644 --- a/src/addons/calendar/services/calendar-sync.ts +++ b/src/addons/calendar/services/calendar-sync.ts @@ -55,7 +55,7 @@ export class AddonCalendarSyncProvider extends CoreSyncBaseProvider { - await this.syncOnSites('all calendar events', this.syncAllEventsFunc.bind(this, force), siteId); + await this.syncOnSites('all calendar events', (siteId) => this.syncAllEventsFunc(force, siteId), siteId); } /** diff --git a/src/addons/competency/services/handlers/course-option.ts b/src/addons/competency/services/handlers/course-option.ts index 1020fcf09..0db2a2687 100644 --- a/src/addons/competency/services/handlers/course-option.ts +++ b/src/addons/competency/services/handlers/course-option.ts @@ -21,8 +21,7 @@ import { } from '@features/course/services/course-options-delegate'; import { makeSingleton } from '@singletons'; import { AddonCompetency } from '../competency'; -import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; -import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper'; +import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { CoreFilterHelper } from '@features/filter/services/filter-helper'; import { ContextLevel } from '@/core/constants'; import { ADDON_COMPETENCY_COMPETENCIES_PAGE } from '@addons/competency/competency.module'; @@ -94,7 +93,7 @@ export class AddonCompetencyCourseOptionHandlerService implements CoreCourseOpti /** * @inheritdoc */ - async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise { + async prefetch(course: CoreCourseAnyCourseData): Promise { // Get the competencies in the course. const competencies = await AddonCompetency.getCourseCompetencies(course.id, undefined, undefined, true); diff --git a/src/addons/coursecompletion/services/handlers/course-option.ts b/src/addons/coursecompletion/services/handlers/course-option.ts index 7fbef1c50..6d7389477 100644 --- a/src/addons/coursecompletion/services/handlers/course-option.ts +++ b/src/addons/coursecompletion/services/handlers/course-option.ts @@ -19,7 +19,7 @@ import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData, } 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 { AddonCourseCompletion } from '../coursecompletion'; @@ -77,7 +77,7 @@ export class AddonCourseCompletionCourseOptionHandlerService implements CoreCour /** * @inheritdoc */ - async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise { + async prefetch(course: CoreCourseAnyCourseData): Promise { try { await AddonCourseCompletion.getCompletion(course.id, undefined, { getFromCache: false, diff --git a/src/addons/messages/services/messages-sync.ts b/src/addons/messages/services/messages-sync.ts index 85fdfe689..745a63fc4 100644 --- a/src/addons/messages/services/messages-sync.ts +++ b/src/addons/messages/services/messages-sync.ts @@ -74,7 +74,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider { 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); } /** diff --git a/src/addons/mod/assign/services/assign-sync.ts b/src/addons/mod/assign/services/assign-sync.ts index 6da554727..ee3e7e3d5 100644 --- a/src/addons/mod/assign/services/assign-sync.ts +++ b/src/addons/mod/assign/services/assign-sync.ts @@ -108,7 +108,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid * @return Promise resolved if sync is successful, rejected if sync fails. */ syncAllAssignments(siteId?: string, force?: boolean): Promise { - return this.syncOnSites('all assignments', this.syncAllAssignmentsFunc.bind(this, !!force), siteId); + return this.syncOnSites('all assignments', (siteId) => this.syncAllAssignmentsFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/mod/assign/services/handlers/prefetch.ts b/src/addons/mod/assign/services/handlers/prefetch.ts index d44a3648a..71302b576 100644 --- a/src/addons/mod/assign/services/handlers/prefetch.ts +++ b/src/addons/mod/assign/services/handlers/prefetch.ts @@ -222,7 +222,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref * @inheritdoc */ prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { - return this.prefetchPackage(module, courseId, this.prefetchAssign.bind(this, module, courseId)); + return this.prefetchPackage(module, courseId, (siteId) => this.prefetchAssign(module, courseId, siteId)); } /** diff --git a/src/addons/mod/chat/services/handlers/prefetch.ts b/src/addons/mod/chat/services/handlers/prefetch.ts index 3a56a30e0..a6414a0a2 100644 --- a/src/addons/mod/chat/services/handlers/prefetch.ts +++ b/src/addons/mod/chat/services/handlers/prefetch.ts @@ -58,7 +58,7 @@ export class AddonModChatPrefetchHandlerService extends CoreCourseActivityPrefet * @inheritdoc */ prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { - return this.prefetchPackage(module, courseId, this.prefetchChat.bind(this, module, courseId)); + return this.prefetchPackage(module, courseId, (siteId) => this.prefetchChat(module, courseId, siteId)); } /** diff --git a/src/addons/mod/choice/services/choice-sync.ts b/src/addons/mod/choice/services/choice-sync.ts index fc34da090..8c4a691c3 100644 --- a/src/addons/mod/choice/services/choice-sync.ts +++ b/src/addons/mod/choice/services/choice-sync.ts @@ -59,7 +59,7 @@ export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvid * @return Promise resolved if sync is successful, rejected if sync fails. */ syncAllChoices(siteId?: string, force?: boolean): Promise { - return this.syncOnSites('all choices', this.syncAllChoicesFunc.bind(this, !!force), siteId); + return this.syncOnSites('all choices', (siteId) => this.syncAllChoicesFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/mod/choice/services/handlers/prefetch.ts b/src/addons/mod/choice/services/handlers/prefetch.ts index 5ae104e28..a45388d8e 100644 --- a/src/addons/mod/choice/services/handlers/prefetch.ts +++ b/src/addons/mod/choice/services/handlers/prefetch.ts @@ -39,7 +39,7 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref * @inheritdoc */ prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise { - return this.prefetchPackage(module, courseId, this.prefetchChoice.bind(this, module, courseId, !!single)); + return this.prefetchPackage(module, courseId, (siteId) => this.prefetchChoice(module, courseId, !!single, siteId)); } /** diff --git a/src/addons/mod/data/components/index/index.ts b/src/addons/mod/data/components/index/index.ts index 024260da0..dac618687 100644 --- a/src/addons/mod/data/components/index/index.ts +++ b/src/addons/mod/data/components/index/index.ts @@ -95,7 +95,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp database: AddonModDataData; title: string; group: number; - gotoEntry: (a: number) => void; + gotoEntry: (entryId: number) => void; }; // Data for found records translation. @@ -372,7 +372,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp database: this.database!, title: this.module.name, group: this.selectedGroup, - gotoEntry: this.gotoEntry.bind(this), + gotoEntry: (entryId) => this.gotoEntry(entryId), }; } else if (!this.search.searching) { // Empty and no searching. diff --git a/src/addons/mod/data/pages/edit/edit.ts b/src/addons/mod/data/pages/edit/edit.ts index 00278b312..260535741 100644 --- a/src/addons/mod/data/pages/edit/edit.ts +++ b/src/addons/mod/data/pages/edit/edit.ts @@ -405,7 +405,7 @@ export class AddonModDataEditPage implements OnInit { form: this.editForm, database: this.database, errors: this.errors, - onFieldInit: this.onFieldInit.bind(this), + onFieldInit: (data) => this.onFieldInit(data), }; let template = AddonModDataHelper.getTemplate(this.database!, AddonModDataTemplateType.ADD, this.fieldsArray); diff --git a/src/addons/mod/data/services/data-offline.ts b/src/addons/mod/data/services/data-offline.ts index 09884cde1..2bb674171 100644 --- a/src/addons/mod/data/services/data-offline.ts +++ b/src/addons/mod/data/services/data-offline.ts @@ -116,7 +116,7 @@ export class AddonModDataOfflineProvider { const site = await CoreSites.getSite(siteId); const entries = await site.getDb().getAllRecords(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', ); - 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 }, ); - return entries.map(this.parseRecord.bind(this)); + return entries.map((entry) => this.parseRecord(entry)); } /** diff --git a/src/addons/mod/data/services/data-sync.ts b/src/addons/mod/data/services/data-sync.ts index b4548616d..1cb1de333 100644 --- a/src/addons/mod/data/services/data-sync.ts +++ b/src/addons/mod/data/services/data-sync.ts @@ -66,7 +66,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider * @return Promise resolved if sync is successful, rejected if sync fails. */ syncAllDatabases(siteId?: string, force?: boolean): Promise { - return this.syncOnSites('all databases', this.syncAllDatabasesFunc.bind(this, !!force), siteId); + return this.syncOnSites('all databases', (siteId) => this.syncAllDatabasesFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/mod/data/services/handlers/prefetch.ts b/src/addons/mod/data/services/handlers/prefetch.ts index 717b69b07..47492dd90 100644 --- a/src/addons/mod/data/services/handlers/prefetch.ts +++ b/src/addons/mod/data/services/handlers/prefetch.ts @@ -207,7 +207,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet * @inheritdoc */ prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { - return this.prefetchPackage(module, courseId, this.prefetchDatabase.bind(this, module, courseId)); + return this.prefetchPackage(module, courseId, (siteId) => this.prefetchDatabase(module, courseId, siteId)); } /** diff --git a/src/addons/mod/feedback/services/feedback-sync.ts b/src/addons/mod/feedback/services/feedback-sync.ts index 291cb4338..723198593 100644 --- a/src/addons/mod/feedback/services/feedback-sync.ts +++ b/src/addons/mod/feedback/services/feedback-sync.ts @@ -65,7 +65,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv * @return Promise resolved if sync is successful, rejected if sync fails. */ syncAllFeedbacks(siteId?: string, force?: boolean): Promise { - 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); 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, })); diff --git a/src/addons/mod/feedback/services/handlers/prefetch.ts b/src/addons/mod/feedback/services/handlers/prefetch.ts index b7f78b3b3..fcd494519 100644 --- a/src/addons/mod/feedback/services/handlers/prefetch.ts +++ b/src/addons/mod/feedback/services/handlers/prefetch.ts @@ -114,7 +114,7 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr * @inheritdoc */ prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { - return this.prefetchPackage(module, courseId, this.prefetchFeedback.bind(this, module, courseId)); + return this.prefetchPackage(module, courseId, (siteId) => this.prefetchFeedback(module, courseId, siteId)); } /** diff --git a/src/addons/mod/forum/components/index/index.ts b/src/addons/mod/forum/components/index/index.ts index 59aa22c5e..37c1491f2 100644 --- a/src/addons/mod/forum/components/index/index.ts +++ b/src/addons/mod/forum/components/index/index.ts @@ -238,11 +238,11 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom // Listen for discussions added. When a discussion is added, we reload the data. this.newDiscObserver = CoreEvents.on( AddonModForumProvider.NEW_DISCUSSION_EVENT, - this.eventReceived.bind(this, true), + (data) => this.eventReceived(true, data), ); this.replyObserver = CoreEvents.on( AddonModForumProvider.REPLY_DISCUSSION_EVENT, - this.eventReceived.bind(this, false), + (data) => this.eventReceived(false, data), ); this.changeDiscObserver = CoreEvents.on(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data => { if (!this.forum) { diff --git a/src/addons/mod/forum/services/forum-sync.ts b/src/addons/mod/forum/services/forum-sync.ts index 7b943afc5..72d01a868 100644 --- a/src/addons/mod/forum/services/forum-sync.ts +++ b/src/addons/mod/forum/services/forum-sync.ts @@ -71,7 +71,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide * @return Promise resolved if sync is successful, rejected if sync fails. */ async syncAllForums(siteId?: string, force?: boolean): Promise { - await this.syncOnSites('all forums', this.syncAllForumsFunc.bind(this, !!force), siteId); + await this.syncOnSites('all forums', (siteId) => this.syncAllForumsFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/mod/forum/services/handlers/prefetch.ts b/src/addons/mod/forum/services/handlers/prefetch.ts index fa9c27762..3ad32b0ab 100644 --- a/src/addons/mod/forum/services/handlers/prefetch.ts +++ b/src/addons/mod/forum/services/handlers/prefetch.ts @@ -204,7 +204,7 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe * @inheritdoc */ prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise { - return this.prefetchPackage(module, courseId, this.prefetchForum.bind(this, module, courseId, single)); + return this.prefetchPackage(module, courseId, (siteId) => this.prefetchForum(module, courseId, !!single, siteId)); } /** diff --git a/src/addons/mod/glossary/classes/glossary-entries-source.ts b/src/addons/mod/glossary/classes/glossary-entries-source.ts index 1bf6fdef7..79aaf675a 100644 --- a/src/addons/mod/glossary/classes/glossary-entries-source.ts +++ b/src/addons/mod/glossary/classes/glossary-entries-source.ts @@ -43,7 +43,7 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource< onlineEntries: AddonModGlossaryEntry[] = []; offlineEntries: AddonModGlossaryOfflineEntry[] = []; - protected fetchFunction?: (options?: AddonModGlossaryGetEntriesOptions) => AddonModGlossaryGetEntriesWSResponse; + protected fetchFunction?: (options?: AddonModGlossaryGetEntriesOptions) => Promise; protected fetchInvalidate?: () => Promise; constructor(courseId: number, cmId: number, glossaryPathPrefix: string) { @@ -162,17 +162,18 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource< return; } - this.fetchFunction = AddonModGlossary.getEntriesBySearch.bind( - AddonModGlossary.instance, - this.glossary.id, + const glossaryId = this.glossary.id; + + this.fetchFunction = (options) => AddonModGlossary.getEntriesBySearch( + glossaryId, query, true, 'CONCEPT', 'ASC', + options, ); - this.fetchInvalidate = AddonModGlossary.invalidateEntriesBySearch.bind( - AddonModGlossary.instance, - this.glossary.id, + this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesBySearch( + glossaryId, query, true, 'CONCEPT', @@ -210,6 +211,7 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource< throw new Error('Can\'t switch entries mode without a glossary!'); } + const glossaryId = this.glossary.id; this.fetchMode = mode; this.isSearch = false; this.setDirty(true); @@ -218,16 +220,15 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource< case 'author_all': // Browse by author. this.viewMode = 'author'; - this.fetchFunction = AddonModGlossary.getEntriesByAuthor.bind( - AddonModGlossary.instance, - this.glossary.id, + this.fetchFunction = (options) => AddonModGlossary.getEntriesByAuthor( + glossaryId, 'ALL', 'LASTNAME', 'ASC', + options, ); - this.fetchInvalidate = AddonModGlossary.invalidateEntriesByAuthor.bind( - AddonModGlossary.instance, - this.glossary.id, + this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesByAuthor( + glossaryId, 'ALL', 'LASTNAME', 'ASC', @@ -237,14 +238,13 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource< case 'cat_all': // Browse by category. this.viewMode = 'cat'; - this.fetchFunction = AddonModGlossary.getEntriesByCategory.bind( - AddonModGlossary.instance, - this.glossary.id, + this.fetchFunction = (options) => AddonModGlossary.getEntriesByCategory( + glossaryId, AddonModGlossaryProvider.SHOW_ALL_CATEGORIES, + options, ); - this.fetchInvalidate = AddonModGlossary.invalidateEntriesByCategory.bind( - AddonModGlossary.instance, - this.glossary.id, + this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesByCategory( + glossaryId, AddonModGlossaryProvider.SHOW_ALL_CATEGORIES, ); break; @@ -252,15 +252,14 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource< case 'newest_first': // Newest first. this.viewMode = 'date'; - this.fetchFunction = AddonModGlossary.getEntriesByDate.bind( - AddonModGlossary.instance, - this.glossary.id, + this.fetchFunction = (options) => AddonModGlossary.getEntriesByDate( + glossaryId, 'CREATION', 'DESC', + options, ); - this.fetchInvalidate = AddonModGlossary.invalidateEntriesByDate.bind( - AddonModGlossary.instance, - this.glossary.id, + this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesByDate( + glossaryId, 'CREATION', 'DESC', ); @@ -269,15 +268,14 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource< case 'recently_updated': // Recently updated. this.viewMode = 'date'; - this.fetchFunction = AddonModGlossary.getEntriesByDate.bind( - AddonModGlossary.instance, - this.glossary.id, + this.fetchFunction = (options) => AddonModGlossary.getEntriesByDate( + glossaryId, 'UPDATE', 'DESC', + options, ); - this.fetchInvalidate = AddonModGlossary.invalidateEntriesByDate.bind( - AddonModGlossary.instance, - this.glossary.id, + this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesByDate( + glossaryId, 'UPDATE', 'DESC', ); @@ -288,14 +286,13 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource< // Consider it is 'letter_all'. this.viewMode = 'letter'; this.fetchMode = 'letter_all'; - this.fetchFunction = AddonModGlossary.getEntriesByLetter.bind( - AddonModGlossary.instance, - this.glossary.id, + this.fetchFunction = (options) => AddonModGlossary.getEntriesByLetter( + glossaryId, 'ALL', + options, ); - this.fetchInvalidate = AddonModGlossary.invalidateEntriesByLetter.bind( - AddonModGlossary.instance, - this.glossary.id, + this.fetchInvalidate = () => AddonModGlossary.invalidateEntriesByLetter( + glossaryId, 'ALL', ); break; diff --git a/src/addons/mod/glossary/services/glossary-sync.ts b/src/addons/mod/glossary/services/glossary-sync.ts index 941adca6d..dc92cf1d1 100644 --- a/src/addons/mod/glossary/services/glossary-sync.ts +++ b/src/addons/mod/glossary/services/glossary-sync.ts @@ -53,7 +53,7 @@ export class AddonModGlossarySyncProvider extends CoreCourseActivitySyncBaseProv * @return Promise resolved if sync is successful, rejected if sync fails. */ syncAllGlossaries(siteId?: string, force?: boolean): Promise { - return this.syncOnSites('all glossaries', this.syncAllGlossariesFunc.bind(this, !!force), siteId); + return this.syncOnSites('all glossaries', (siteId) => this.syncAllGlossariesFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/mod/glossary/services/glossary.ts b/src/addons/mod/glossary/services/glossary.ts index 4b31042e5..60d0ed11a 100644 --- a/src/addons/mod/glossary/services/glossary.ts +++ b/src/addons/mod/glossary/services/glossary.ts @@ -759,7 +759,7 @@ export class AddonModGlossaryProvider { const promises: Promise[] = []; 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, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE, siteId, @@ -993,7 +993,7 @@ export class AddonModGlossaryProvider { // If we get here, there's no offline entry with this name, check online. // 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, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE, siteId: options.siteId, diff --git a/src/addons/mod/glossary/services/handlers/prefetch.ts b/src/addons/mod/glossary/services/handlers/prefetch.ts index 9945e4872..c62f67ac2 100644 --- a/src/addons/mod/glossary/services/handlers/prefetch.ts +++ b/src/addons/mod/glossary/services/handlers/prefetch.ts @@ -45,7 +45,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr const glossary = await AddonModGlossary.getGlossary(courseId, module.id); const entries = await AddonModGlossary.fetchAllEntries( - AddonModGlossary.getEntriesByLetter.bind(AddonModGlossary.instance, glossary.id, 'ALL'), + (options) => AddonModGlossary.getEntriesByLetter(glossary.id, 'ALL', options), { cmId: module.id, }, @@ -96,7 +96,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr * @inheritdoc */ prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { - 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; case 'cat': promises.push(AddonModGlossary.fetchAllEntries( - AddonModGlossary.getEntriesByCategory.bind( - AddonModGlossary.instance, + (newOptions) => AddonModGlossary.getEntriesByCategory( glossary.id, AddonModGlossaryProvider.SHOW_ALL_CATEGORIES, + newOptions, ), options, )); break; case 'date': promises.push(AddonModGlossary.fetchAllEntries( - AddonModGlossary.getEntriesByDate.bind( - AddonModGlossary.instance, + (newOptions) => AddonModGlossary.getEntriesByDate( glossary.id, 'CREATION', 'DESC', + newOptions, ), options, )); promises.push(AddonModGlossary.fetchAllEntries( - AddonModGlossary.getEntriesByDate.bind( - AddonModGlossary.instance, + (newOptions) => AddonModGlossary.getEntriesByDate( glossary.id, 'UPDATE', 'DESC', + newOptions, ), options, )); break; case 'author': promises.push(AddonModGlossary.fetchAllEntries( - AddonModGlossary.getEntriesByAuthor.bind( - AddonModGlossary.instance, + (newOptions) => AddonModGlossary.getEntriesByAuthor( glossary.id, 'ALL', 'LASTNAME', 'ASC', + newOptions, ), options, )); @@ -171,7 +171,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr // Fetch all entries to get information from. promises.push(AddonModGlossary.fetchAllEntries( - AddonModGlossary.getEntriesByLetter.bind(AddonModGlossary.instance, glossary.id, 'ALL'), + (newOptions) => AddonModGlossary.getEntriesByLetter(glossary.id, 'ALL', newOptions), options, ).then((entries) => { const promises: Promise[] = []; diff --git a/src/addons/mod/h5pactivity/components/index/index.ts b/src/addons/mod/h5pactivity/components/index/index.ts index be5b42515..4cb9e17ed 100644 --- a/src/addons/mod/h5pactivity/components/index/index.ts +++ b/src/addons/mod/h5pactivity/components/index/index.ts @@ -98,7 +98,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv this.siteCanDownload = this.site.canDownloadFiles() && !CoreH5P.isOfflineDisabledInSite(); // Listen for messages from the iframe. - this.messageListenerFunction = this.onIframeMessage.bind(this); + this.messageListenerFunction = (event) => this.onIframeMessage(event); window.addEventListener('message', this.messageListenerFunction); } diff --git a/src/addons/mod/h5pactivity/services/h5pactivity-sync.ts b/src/addons/mod/h5pactivity/services/h5pactivity-sync.ts index 48d2f172c..37022b939 100644 --- a/src/addons/mod/h5pactivity/services/h5pactivity-sync.ts +++ b/src/addons/mod/h5pactivity/services/h5pactivity-sync.ts @@ -48,7 +48,7 @@ export class AddonModH5PActivitySyncProvider extends CoreCourseActivitySyncBaseP * @return Promise resolved if sync is successful, rejected if sync fails. */ syncAllActivities(siteId?: string, force?: boolean): Promise { - return this.syncOnSites('H5P activities', this.syncAllActivitiesFunc.bind(this, !!force), siteId); + return this.syncOnSites('H5P activities', (siteId) => this.syncAllActivitiesFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/mod/h5pactivity/services/handlers/prefetch.ts b/src/addons/mod/h5pactivity/services/handlers/prefetch.ts index 98309cf0a..3e4a53b11 100644 --- a/src/addons/mod/h5pactivity/services/handlers/prefetch.ts +++ b/src/addons/mod/h5pactivity/services/handlers/prefetch.ts @@ -77,7 +77,7 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit * @inheritdoc */ prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { - return this.prefetchPackage(module, courseId, this.prefetchActivity.bind(this, module, courseId)); + return this.prefetchPackage(module, courseId, (siteId) => this.prefetchActivity(module, courseId, siteId)); } /** diff --git a/src/addons/mod/lesson/pages/player/player.page.ts b/src/addons/mod/lesson/pages/player/player.page.ts index 1eab60f21..3fdcb3cf5 100644 --- a/src/addons/mod/lesson/pages/player/player.page.ts +++ b/src/addons/mod/lesson/pages/player/player.page.ts @@ -285,12 +285,13 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { this.offline = true; } + const lessonId = this.lesson.id; const options = { cmId: this.cmId, readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK, }; this.accessInfo = await this.callFunction( - AddonModLesson.getAccessInformation.bind(AddonModLesson.instance, this.lesson.id, options), + () => AddonModLesson.getAccessInformation(lessonId, options), options, ); @@ -321,7 +322,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK, }; promises.push(this.callFunction( - AddonModLesson.getLessonWithPassword.bind(AddonModLesson.instance, this.lesson.id, options), + () => AddonModLesson.getLessonWithPassword(lessonId, options), options, ).then((lesson) => { this.lesson = lesson; @@ -373,17 +374,22 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { * @return Promise resolved when done. */ protected async finishRetake(outOfTime?: boolean): Promise { + if (!this.lesson) { + return; + } + + const lesson = this.lesson; this.messages = []; if (this.offline && CoreNetwork.isOnline()) { // Offline mode but the app is online. Try to sync the data. const result = await CoreUtils.ignoreErrors( - AddonModLessonSync.syncLesson(this.lesson!.id, true, true), + AddonModLessonSync.syncLesson(lesson.id, true, true), ); if (result?.warnings?.length) { // 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, }); @@ -411,11 +417,11 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { accessInfo: this.accessInfo, }; const data = await this.callFunction( - AddonModLesson.finishRetake.bind(AddonModLesson.instance, this.lesson, this.courseId, options), + () => AddonModLesson.finishRetake(lesson, this.courseId, options), options, ); - this.title = this.lesson!.name; + this.title = lesson.name; this.eolData = data.data; this.messages = this.messages.concat(data.messages); this.processData = undefined; @@ -512,13 +518,14 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { * @return Promise resolved when done. */ protected async loadMenu(): Promise { - if (this.loadingMenu) { + if (this.loadingMenu || !this.lesson) { // Already loading. return; } try { this.loadingMenu = true; + const lessonId = this.lesson.id; const options = { password: this.password, cmId: this.cmId, @@ -526,7 +533,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { }; const pages = await this.callFunction( - AddonModLesson.getPages.bind(AddonModLesson.instance, this.lesson!.id, options), + () => AddonModLesson.getPages(lessonId, options), options, ); @@ -548,8 +555,11 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { if (pageId == AddonModLessonProvider.LESSON_EOL) { // End of lesson reached. return this.finishRetake(); + } else if (!this.lesson) { + return; } + const lesson = this.lesson; const options = { password: this.password, review: this.review, @@ -562,7 +572,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { }; const data = await this.callFunction( - AddonModLesson.getPageData.bind(AddonModLesson.instance, this.lesson, pageId, options), + () => AddonModLesson.getPageData(lesson, pageId, options), options, ); @@ -615,8 +625,14 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { * @return Promise resolved when done. */ protected async processPage(data: CoreFormFields, formSubmitted?: boolean): Promise { + if (!this.lesson || !this.pageData) { + return; + } + this.loaded = false; + const lesson = this.lesson; + const pageData = this.pageData; const options: AddonModLessonProcessPageOptions = { password: this.password, review: this.review, @@ -627,11 +643,10 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { try { const result = await this.callFunction( - AddonModLesson.processPage.bind( - AddonModLesson.instance, - this.lesson, + () => AddonModLesson.processPage( + lesson, this.courseId, - this.pageData, + pageData, data, 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. const retake = this.accessInfo!.attemptscount; 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. if (AddonModLesson.isQuestionPage(this.pageData?.page?.type || -1)) { - AddonModLesson.getQuestionsAttemptsOnline(this.lesson!.id, retake, options); + AddonModLesson.getQuestionsAttemptsOnline(lesson.id, retake, options); } 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.processDataButtons = []; - if (this.lesson!.review && !result.correctanswer && !result.noanswer && !result.isessayquestion && + if (lesson.review && !result.correctanswer && !result.noanswer && !result.isessayquestion && !result.maxattemptsreached && !result.reviewmode) { // User can try again, show button to do so. this.processDataButtons.push({ @@ -683,11 +698,11 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { } // Button to continue. - if (this.lesson!.review && !result.correctanswer && !result.noanswer && !result.isessayquestion && + if (lesson.review && !result.correctanswer && !result.noanswer && !result.isessayquestion && !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 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). this.processDataButtons.push({ label: 'addon.mod_lesson.reviewquestioncontinue', diff --git a/src/addons/mod/lesson/services/handlers/prefetch.ts b/src/addons/mod/lesson/services/handlers/prefetch.ts index a9455ee70..25fcd15b7 100644 --- a/src/addons/mod/lesson/services/handlers/prefetch.ts +++ b/src/addons/mod/lesson/services/handlers/prefetch.ts @@ -225,7 +225,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref * @inheritdoc */ prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise { - return this.prefetchPackage(module, courseId, this.prefetchLesson.bind(this, module, courseId, !!single)); + return this.prefetchPackage(module, courseId, (siteId) => this.prefetchLesson(module, courseId, !!single, siteId)); } /** diff --git a/src/addons/mod/lesson/services/lesson-sync.ts b/src/addons/mod/lesson/services/lesson-sync.ts index ef2c6923e..604cdc429 100644 --- a/src/addons/mod/lesson/services/lesson-sync.ts +++ b/src/addons/mod/lesson/services/lesson-sync.ts @@ -122,7 +122,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid * @return Promise resolved if sync is successful, rejected if sync fails. */ syncAllLessons(siteId?: string, force = false): Promise { - 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); 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, })); diff --git a/src/addons/mod/quiz/services/handlers/prefetch.ts b/src/addons/mod/quiz/services/handlers/prefetch.ts index dedc71db5..91ae7962a 100644 --- a/src/addons/mod/quiz/services/handlers/prefetch.ts +++ b/src/addons/mod/quiz/services/handlers/prefetch.ts @@ -278,7 +278,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet 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)); } /** diff --git a/src/addons/mod/quiz/services/quiz-sync.ts b/src/addons/mod/quiz/services/quiz-sync.ts index 84abd5e4b..62904829f 100644 --- a/src/addons/mod/quiz/services/quiz-sync.ts +++ b/src/addons/mod/quiz/services/quiz-sync.ts @@ -180,7 +180,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider * @return Promise resolved if sync is successful, rejected if sync fails. */ syncAllQuizzes(siteId?: string, force?: boolean): Promise { - return this.syncOnSites('all quizzes', this.syncAllQuizzesFunc.bind(this, !!force), siteId); + return this.syncOnSites('all quizzes', (siteId) => this.syncAllQuizzesFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/mod/resource/services/handlers/module.ts b/src/addons/mod/resource/services/handlers/module.ts index a67fe7926..cabdda495 100644 --- a/src/addons/mod/resource/services/handlers/module.ts +++ b/src/addons/mod/resource/services/handlers/module.ts @@ -70,7 +70,10 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase sectionId?: number, forCoursePage?: boolean, ): Promise { - const updateStatus = (status: string): void => { + const openWithPicker = CoreFileHelper.defaultIsOpenWithPicker(); + + const handlerData = await super.getData(module, courseId, sectionId, forCoursePage); + handlerData.updateStatus = (status) => { if (!handlerData.buttons) { return; } @@ -78,10 +81,6 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase handlerData.buttons[0].hidden = status !== CoreConstants.DOWNLOADED || AddonModResourceHelper.isDisplayedInIframe(module); }; - const openWithPicker = CoreFileHelper.defaultIsOpenWithPicker(); - - const handlerData = await super.getData(module, courseId, sectionId, forCoursePage); - handlerData.updateStatus = updateStatus.bind(this); handlerData.buttons = [{ hidden: true, icon: openWithPicker ? 'fas-share-square' : 'fas-file', diff --git a/src/addons/mod/scorm/classes/data-model-12.ts b/src/addons/mod/scorm/classes/data-model-12.ts index 7f7f48582..dd37ab93f 100644 --- a/src/addons/mod/scorm/classes/data-model-12.ts +++ b/src/addons/mod/scorm/classes/data-model-12.ts @@ -883,7 +883,7 @@ export class AddonModScormDataModel12 { // Store data. if (this.errorCode == '0') { 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; diff --git a/src/addons/mod/scorm/pages/player/player.ts b/src/addons/mod/scorm/pages/player/player.ts index 8303adb5d..5449c840f 100644 --- a/src/addons/mod/scorm/pages/player/player.ts +++ b/src/addons/mod/scorm/pages/player/player.ts @@ -175,7 +175,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { if (this.offline) { // Wait a bit to make sure data is stored. - setTimeout(this.refreshToc.bind(this), 100); + setTimeout(() => this.refreshToc(), 100); } else { this.refreshToc(); } diff --git a/src/addons/mod/scorm/services/handlers/prefetch.ts b/src/addons/mod/scorm/services/handlers/prefetch.ts index b935d1f61..a64880029 100644 --- a/src/addons/mod/scorm/services/handlers/prefetch.ts +++ b/src/addons/mod/scorm/services/handlers/prefetch.ts @@ -50,7 +50,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe return this.prefetchPackage( module, 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, undefined, undefined, - this.downloadProgress.bind(this, true, onProgress), + (event: ProgressEvent) => this.downloadProgress(true, onProgress, event), ); } else { await CoreFilepool.downloadUrl( @@ -136,7 +136,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe this.component, scorm.coursemodule, undefined, - this.downloadProgress.bind(this, true, onProgress), + (event: ProgressEvent) => this.downloadProgress(true, onProgress, event), ); } @@ -147,7 +147,11 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe onProgress && onProgress({ message: 'core.unzipping' }); // 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) => this.downloadProgress(false, onProgress, event), + ); await CoreUtils.ignoreErrors(CoreFilepool.removeFileByUrl(siteId, packageUrl)); } @@ -371,7 +375,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe return this.prefetchPackage( module, courseId, - this.downloadOrPrefetchScorm.bind(this, module, courseId, single, true, onProgress), + (siteId) => this.downloadOrPrefetchScorm(module, courseId, !!single, true, onProgress, siteId), ); } diff --git a/src/addons/mod/scorm/services/scorm-sync.ts b/src/addons/mod/scorm/services/scorm-sync.ts index f3100d10c..52ddf4ff9 100644 --- a/src/addons/mod/scorm/services/scorm-sync.ts +++ b/src/addons/mod/scorm/services/scorm-sync.ts @@ -445,7 +445,7 @@ export class AddonModScormSyncProvider extends CoreCourseActivitySyncBaseProvide * @return Promise resolved if sync is successful, rejected if sync fails. */ syncAllScorms(siteId?: string, force?: boolean): Promise { - return this.syncOnSites('all SCORMs', this.syncAllScormsFunc.bind(this, !!force), siteId); + return this.syncOnSites('all SCORMs', (siteId) => this.syncAllScormsFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/mod/survey/services/handlers/prefetch.ts b/src/addons/mod/survey/services/handlers/prefetch.ts index 31ffcff48..d7bdd4baa 100644 --- a/src/addons/mod/survey/services/handlers/prefetch.ts +++ b/src/addons/mod/survey/services/handlers/prefetch.ts @@ -68,7 +68,7 @@ export class AddonModSurveyPrefetchHandlerService extends CoreCourseActivityPref * @inheritdoc */ prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { - return this.prefetchPackage(module, courseId, this.prefetchSurvey.bind(this, module, courseId)); + return this.prefetchPackage(module, courseId, (siteId) => this.prefetchSurvey(module, courseId, siteId)); } /** diff --git a/src/addons/mod/survey/services/survey-sync.ts b/src/addons/mod/survey/services/survey-sync.ts index f3389b3db..d228db82f 100644 --- a/src/addons/mod/survey/services/survey-sync.ts +++ b/src/addons/mod/survey/services/survey-sync.ts @@ -60,7 +60,7 @@ export class AddonModSurveySyncProvider extends CoreCourseActivitySyncBaseProvid * @return Promise resolved if sync is successful, rejected if sync fails. */ syncAllSurveys(siteId?: string, force?: boolean): Promise { - return this.syncOnSites('all surveys', this.syncAllSurveysFunc.bind(this, !!force), siteId); + return this.syncOnSites('all surveys', (siteId) => this.syncAllSurveysFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/mod/wiki/services/handlers/prefetch.ts b/src/addons/mod/wiki/services/handlers/prefetch.ts index c804afecd..93b543a41 100644 --- a/src/addons/mod/wiki/services/handlers/prefetch.ts +++ b/src/addons/mod/wiki/services/handlers/prefetch.ts @@ -140,7 +140,7 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet return this.prefetchPackage( module, courseId, - this.prefetchWiki.bind(this, module, courseId, !!single, downloadTime), + (siteId) => this.prefetchWiki(module, courseId, !!single, downloadTime, siteId), siteId, ); } diff --git a/src/addons/mod/wiki/services/wiki-sync.ts b/src/addons/mod/wiki/services/wiki-sync.ts index 7cc5b4c8e..89586dd5e 100644 --- a/src/addons/mod/wiki/services/wiki-sync.ts +++ b/src/addons/mod/wiki/services/wiki-sync.ts @@ -73,7 +73,7 @@ export class AddonModWikiSyncProvider extends CoreSyncBaseProvider { - return this.syncOnSites('all wikis', this.syncAllWikisFunc.bind(this, !!force), siteId); + return this.syncOnSites('all wikis', (siteId) => this.syncAllWikisFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts index 78b028706..81c20524e 100644 --- a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts +++ b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts @@ -135,8 +135,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe await this.load(); this.obsInvalidated = CoreEvents.on( AddonModWorkshopProvider.ASSESSMENT_INVALIDATED, - this.load.bind(this), - + () => this.load(), CoreSites.getCurrentSiteId(), ); } catch (error) { diff --git a/src/addons/mod/workshop/services/handlers/prefetch.ts b/src/addons/mod/workshop/services/handlers/prefetch.ts index 789b57f9f..22b4fcc44 100644 --- a/src/addons/mod/workshop/services/handlers/prefetch.ts +++ b/src/addons/mod/workshop/services/handlers/prefetch.ts @@ -205,7 +205,7 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr * @inheritdoc */ prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise { - return this.prefetchPackage(module, courseId, this.prefetchWorkshop.bind(this, module, courseId)); + return this.prefetchPackage(module, courseId, (siteId) => this.prefetchWorkshop(module, courseId, siteId)); } /** diff --git a/src/addons/mod/workshop/services/workshop-offline.ts b/src/addons/mod/workshop/services/workshop-offline.ts index 1246ef1f1..0884e9403 100644 --- a/src/addons/mod/workshop/services/workshop-offline.ts +++ b/src/addons/mod/workshop/services/workshop-offline.ts @@ -141,7 +141,7 @@ export class AddonModWorkshopOfflineProvider { const records = await site.getDb().getRecords(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(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(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(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(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 = await site.getDb().getRecords(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(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 = await site.getDb().getRecords(EVALUATE_ASSESSMENTS_TABLE, conditions); - return records.map(this.parseEvaluateAssessmentRecord.bind(this)); + return records.map((record) => this.parseEvaluateAssessmentRecord(record)); } /** diff --git a/src/addons/mod/workshop/services/workshop-sync.ts b/src/addons/mod/workshop/services/workshop-sync.ts index 6999fc8b2..7f5d4768b 100644 --- a/src/addons/mod/workshop/services/workshop-sync.ts +++ b/src/addons/mod/workshop/services/workshop-sync.ts @@ -73,7 +73,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider { - return this.syncOnSites('all workshops', this.syncAllWorkshopsFunc.bind(this, !!force), siteId); + return this.syncOnSites('all workshops', (siteId) => this.syncAllWorkshopsFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/notes/services/handlers/course-option.ts b/src/addons/notes/services/handlers/course-option.ts index 646af845c..77c7d54e4 100644 --- a/src/addons/notes/services/handlers/course-option.ts +++ b/src/addons/notes/services/handlers/course-option.ts @@ -19,8 +19,7 @@ import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData, } from '@features/course/services/course-options-delegate'; -import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; -import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper'; +import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { makeSingleton } from '@singletons'; import { AddonNotes } from '../notes'; @@ -73,7 +72,7 @@ export class AddonNotesCourseOptionHandlerService implements CoreCourseOptionsHa /** * @inheritdoc */ - async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise { + async prefetch(course: CoreCourseAnyCourseData): Promise { await AddonNotes.getNotes(course.id, undefined, true); } diff --git a/src/addons/notes/services/notes-sync.ts b/src/addons/notes/services/notes-sync.ts index f5554338c..dc6f1eae4 100644 --- a/src/addons/notes/services/notes-sync.ts +++ b/src/addons/notes/services/notes-sync.ts @@ -45,7 +45,7 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider { - return this.syncOnSites('all notes', this.syncAllNotesFunc.bind(this, !!force), siteId); + return this.syncOnSites('all notes', (siteId) => this.syncAllNotesFunc(!!force, siteId), siteId); } /** diff --git a/src/addons/notifications/pages/notification/notification.ts b/src/addons/notifications/pages/notification/notification.ts index 6e161cec4..a53e5fa26 100644 --- a/src/addons/notifications/pages/notification/notification.ts +++ b/src/addons/notifications/pages/notification/notification.ts @@ -183,7 +183,7 @@ export class AddonNotificationsNotificationPage implements OnInit, OnDestroy { actions.push({ message: 'core.view', icon: 'fas-eye', - action: this.openInBrowser.bind(this), + action: (siteId) => this.openInBrowser(siteId), }); } diff --git a/src/addons/qbehaviour/deferredcbm/services/handlers/deferredcbm.ts b/src/addons/qbehaviour/deferredcbm/services/handlers/deferredcbm.ts index c4af00249..f5d3edec2 100644 --- a/src/addons/qbehaviour/deferredcbm/services/handlers/deferredcbm.ts +++ b/src/addons/qbehaviour/deferredcbm/services/handlers/deferredcbm.ts @@ -55,8 +55,8 @@ export class AddonQbehaviourDeferredCBMHandlerService implements CoreQuestionBeh question, componentId, siteId, - this.isCompleteResponse.bind(this), - this.isSameResponse.bind(this), + (...args) => this.isCompleteResponse(...args), + (...args) => this.isSameResponse(...args), ); } diff --git a/src/core/classes/delegate-sorted.ts b/src/core/classes/delegate-sorted.ts index 829eb0399..30827a99b 100644 --- a/src/core/classes/delegate-sorted.ts +++ b/src/core/classes/delegate-sorted.ts @@ -39,7 +39,7 @@ export class CoreSortedDelegate< constructor(delegateName: string) { super(delegateName, true); - CoreEvents.on(CoreEvents.LOGOUT, this.clearSortedHandlers.bind(this)); + CoreEvents.on(CoreEvents.LOGOUT, () => this.clearSortedHandlers()); CoreEvents.on(CoreEvents.SITE_POLICY_AGREED, (data) => { if (data.siteId === CoreSites.getCurrentSiteId()) { // 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. - CoreEvents.on(CoreEvents.LOGIN, this.clearSortedHandlers.bind(this)); + CoreEvents.on(CoreEvents.LOGIN, () => this.clearSortedHandlers()); } /** diff --git a/src/core/classes/delegate.ts b/src/core/classes/delegate.ts index 3651bcc67..7d34c7450 100644 --- a/src/core/classes/delegate.ts +++ b/src/core/classes/delegate.ts @@ -95,9 +95,9 @@ export class CoreDelegate { if (listenSiteEvents) { // Update handlers on this cases. - CoreEvents.on(CoreEvents.LOGIN, this.updateHandlers.bind(this)); - CoreEvents.on(CoreEvents.SITE_UPDATED, this.updateHandlers.bind(this)); - CoreEvents.on(CoreEvents.SITE_PLUGINS_LOADED, this.updateHandlers.bind(this)); + CoreEvents.on(CoreEvents.LOGIN, () => this.updateHandlers()); + CoreEvents.on(CoreEvents.SITE_UPDATED, () => this.updateHandlers()); + CoreEvents.on(CoreEvents.SITE_PLUGINS_LOADED, () => this.updateHandlers()); CoreEvents.on(CoreEvents.SITE_POLICY_AGREED, (data) => { if (data.siteId === CoreSites.getCurrentSiteId()) { this.updateHandlers(); diff --git a/src/core/classes/promised-value.ts b/src/core/classes/promised-value.ts index 02ff73b25..bedefc5cd 100644 --- a/src/core/classes/promised-value.ts +++ b/src/core/classes/promised-value.ts @@ -29,8 +29,8 @@ export class CorePromisedValue extends CorePromise { const promisedValue = new CorePromisedValue(); promise - .then(promisedValue.resolve.bind(promisedValue)) - .catch(promisedValue.reject.bind(promisedValue)); + .then(value => promisedValue.resolve(value)) + .catch(error => promisedValue.reject(error)); return promisedValue; } diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index e0dcf4853..43f058af3 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -994,7 +994,7 @@ export class CoreSite { this.processRequestQueue(); } else if (!this.requestQueueTimeout) { this.requestQueueTimeout = window.setTimeout( - this.processRequestQueue.bind(this), + () => this.processRequestQueue(), CoreConstants.CONFIG.wsrequestqueuedelay, ); } diff --git a/src/core/classes/tabs.ts b/src/core/classes/tabs.ts index c5cac4b9c..294d96ca4 100644 --- a/src/core/classes/tabs.ts +++ b/src/core/classes/tabs.ts @@ -95,7 +95,7 @@ export class CoreTabsBaseComponent implements OnInit, Aft tabAction: CoreTabsRoleTab; constructor(element: ElementRef) { - this.backButtonFunction = this.backButtonClicked.bind(this); + this.backButtonFunction = (event) => this.backButtonClicked(event); this.tabAction = new CoreTabsRoleTab(this); diff --git a/src/core/components/context-menu/context-menu-popover.ts b/src/core/components/context-menu/context-menu-popover.ts index 46461b45f..4cb3c4f4c 100644 --- a/src/core/components/context-menu/context-menu-popover.ts +++ b/src/core/components/context-menu/context-menu-popover.ts @@ -73,7 +73,7 @@ export class CoreContextMenuPopoverComponent { 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))) { this.closeMenu(item); } diff --git a/src/core/components/infinite-loading/infinite-loading.ts b/src/core/components/infinite-loading/infinite-loading.ts index 370c2473a..814416cbb 100644 --- a/src/core/components/infinite-loading/infinite-loading.ts +++ b/src/core/components/infinite-loading/infinite-loading.ts @@ -103,7 +103,7 @@ export class CoreInfiniteLoadingComponent implements OnChanges { } 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 { if (this.position == 'top') { // 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 { this.completeLoadMore(); } diff --git a/src/core/directives/collapsible-item.ts b/src/core/directives/collapsible-item.ts index 1a4950c8b..a5c44c5eb 100644 --- a/src/core/directives/collapsible-item.ts +++ b/src/core/directives/collapsible-item.ts @@ -64,7 +64,7 @@ export class CoreCollapsibleItemDirective implements OnInit, OnDestroy { constructor(el: ElementRef) { 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.element.id = this.uniqueId; } diff --git a/src/core/directives/format-text.ts b/src/core/directives/format-text.ts index 2b9caef1f..94ed7d5eb 100644 --- a/src/core/directives/format-text.ts +++ b/src/core/directives/format-text.ts @@ -116,7 +116,7 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncCompo this.afterRender = new EventEmitter(); - this.element.addEventListener('click', this.elementClicked.bind(this)); + this.element.addEventListener('click', (event) => this.elementClicked(event)); this.siteId = this.siteId || CoreSites.getCurrentSiteId(); } diff --git a/src/core/directives/supress-events.ts b/src/core/directives/supress-events.ts index 559558129..2a0179c2c 100644 --- a/src/core/directives/supress-events.ts +++ b/src/core/directives/supress-events.ts @@ -80,7 +80,7 @@ export class CoreSupressEventsDirective implements OnInit { // Suppress the 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. diff --git a/src/core/features/comments/services/comments-sync.ts b/src/core/features/comments/services/comments-sync.ts index cf19944cf..8efab2e35 100644 --- a/src/core/features/comments/services/comments-sync.ts +++ b/src/core/features/comments/services/comments-sync.ts @@ -44,7 +44,7 @@ export class CoreCommentsSyncProvider extends CoreSyncBaseProvider { - return this.syncOnSites('all comments', this.syncAllCommentsFunc.bind(this, !!force), siteId); + return this.syncOnSites('all comments', (siteId) => this.syncAllCommentsFunc(!!force, siteId), siteId); } /** diff --git a/src/core/features/contentlinks/services/contentlinks-delegate.ts b/src/core/features/contentlinks/services/contentlinks-delegate.ts index fa8e6575e..8f6823193 100644 --- a/src/core/features/contentlinks/services/contentlinks-delegate.ts +++ b/src/core/features/contentlinks/services/contentlinks-delegate.ts @@ -179,7 +179,7 @@ export class CoreContentLinksDelegateService { for (const name in this.handlers) { const handler = this.handlers[name]; 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)) { // Invalid handler or it doesn't handle the URL. Stop. @@ -282,7 +282,7 @@ export class CoreContentLinksDelegateService { handler: CoreContentLinksHandler, url: string, params: Record, - courseId: number, + courseId: number | undefined, siteId: string, ): Promise { diff --git a/src/core/features/course/classes/activity-prefetch-handler.ts b/src/core/features/course/classes/activity-prefetch-handler.ts index a1daa22db..357efa498 100644 --- a/src/core/features/course/classes/activity-prefetch-handler.ts +++ b/src/core/features/course/classes/activity-prefetch-handler.ts @@ -65,21 +65,18 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe * Prefetch the module, setting package status at start and finish. * * Example usage from a child instance: - * return this.prefetchPackage(module, courseId, single, this.prefetchModule.bind(this, otherParam), siteId); - * - * Then the function "prefetchModule" will receive params: - * prefetchModule(module, courseId, single, siteId, someParam, anotherParam) + * return this.prefetchPackage(module, courseId, (siteId) => this.prefetchModule(module, otherParam, siteId), siteId); * * @param module Module. * @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. * @return Promise resolved when the module has been downloaded. Data returned is not reliable. */ async prefetchPackage( module: CoreCourseAnyModuleData, courseId: number, - downloadFunction: (siteId: string) => Promise, + downloadFunction: (siteId: string) => Promise, siteId?: string, ): Promise { siteId = siteId || CoreSites.getCurrentSiteId(); @@ -104,14 +101,14 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe * * @param module Module. * @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. * @return Promise resolved when the module has been downloaded. Data returned is not reliable. */ protected async changeStatusAndPrefetch( module: CoreCourseAnyModuleData, courseId: number | undefined, - downloadFunction: (siteId: string) => Promise, + downloadFunction: (siteId: string) => Promise, siteId: string, ): Promise { try { diff --git a/src/core/features/course/services/course-options-delegate.ts b/src/core/features/course/services/course-options-delegate.ts index 7c4a4a62e..a5a4ae720 100644 --- a/src/core/features/course/services/course-options-delegate.ts +++ b/src/core/features/course/services/course-options-delegate.ts @@ -90,7 +90,7 @@ export interface CoreCourseOptionsHandler extends CoreDelegateHandler { * @param course The course. * @return Promise resolved when done. */ - prefetch?(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise; + prefetch?(course: CoreCourseAnyCourseData): Promise; } /** @@ -452,7 +452,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate await handler.prefetch?.(course), name: handler.name, }); diff --git a/src/core/features/course/services/module-prefetch-delegate.ts b/src/core/features/course/services/module-prefetch-delegate.ts index 944a887d6..2a8b254d9 100644 --- a/src/core/features/course/services/module-prefetch-delegate.ts +++ b/src/core/features/course/services/module-prefetch-delegate.ts @@ -61,7 +61,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate this.clearStatusCache()); CoreEvents.on(CoreEvents.PACKAGE_STATUS_CHANGED, (data) => { this.updateStatusCache(data.status, data.component, data.componentId); diff --git a/src/core/features/course/services/sync.ts b/src/core/features/course/services/sync.ts index ab604bb89..773486202 100644 --- a/src/core/features/course/services/sync.ts +++ b/src/core/features/course/services/sync.ts @@ -51,7 +51,7 @@ export class CoreCourseSyncProvider extends CoreSyncBaseProvider { - return this.syncOnSites('courses', this.syncAllCoursesFunc.bind(this, !!force), siteId); + return this.syncOnSites('courses', (siteId) => this.syncAllCoursesFunc(!!force, siteId), siteId); } /** diff --git a/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts b/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts index ac0ceebf9..14224e13b 100644 --- a/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts +++ b/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts @@ -171,11 +171,11 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit, this.setContent(this.control?.value); this.originalContent = this.control?.value; this.lastDraft = this.control?.value; - this.editorElement.onchange = this.onChange.bind(this); - this.editorElement.onkeyup = this.onChange.bind(this); - this.editorElement.onpaste = this.onChange.bind(this); - this.editorElement.oninput = this.onChange.bind(this); - this.editorElement.onkeydown = this.moveCursor.bind(this); + this.editorElement.onchange = () => this.onChange(); + this.editorElement.onkeyup = () => this.onChange(); + this.editorElement.onpaste = () => this.onChange(); + this.editorElement.oninput = () => this.onChange(); + this.editorElement.onkeydown = event => this.moveCursor(event); // Use paragraph on enter. document.execCommand('DefaultParagraphSeparator', false, 'p'); @@ -258,7 +258,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit, this.windowResized(); }, 50); - document.addEventListener('selectionchange', this.selectionChangeFunction = this.updateToolbarStyles.bind(this)); + document.addEventListener('selectionchange', this.selectionChangeFunction = () => this.updateToolbarStyles()); 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. diff --git a/src/core/features/emulator/services/geolocation.ts b/src/core/features/emulator/services/geolocation.ts index bd88b52fa..2f7ef778b 100644 --- a/src/core/features/emulator/services/geolocation.ts +++ b/src/core/features/emulator/services/geolocation.ts @@ -47,8 +47,8 @@ export class GeolocationMock extends Geolocation { watchPosition(options?: GeolocationOptions): Observable { return new Observable((subscriber: Subscriber): TeardownLogic => { const watchId = navigator.geolocation.watchPosition( - subscriber.next.bind(subscriber), - subscriber.error.bind(subscriber), + position => subscriber.next( position), + error => subscriber.error(error), options, ); diff --git a/src/core/features/fileuploader/services/fileuploader-delegate.ts b/src/core/features/fileuploader/services/fileuploader-delegate.ts index 6614590a9..c13b6e2be 100644 --- a/src/core/features/fileuploader/services/fileuploader-delegate.ts +++ b/src/core/features/fileuploader/services/fileuploader-delegate.ts @@ -145,7 +145,7 @@ export class CoreFileUploaderDelegateService extends CoreDelegate this.clearSiteHandlers()); } /** diff --git a/src/core/features/filter/services/filter-helper.ts b/src/core/features/filter/services/filter-helper.ts index ea3fbfce4..6a1f980fd 100644 --- a/src/core/features/filter/services/filter-helper.ts +++ b/src/core/features/filter/services/filter-helper.ts @@ -218,6 +218,7 @@ export class CoreFilterHelperProvider { return CoreFilterDelegate.getEnabledFilters(contextLevel, instanceId); } + const courseId = options.courseId; let hasFilters = true; if (contextLevel == 'system' || (contextLevel == 'course' && instanceId == site.getSiteHomeId())) { @@ -233,20 +234,20 @@ export class CoreFilterHelperProvider { 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. - const getFilters = this.getCourseModulesContexts.bind(this, options.courseId, siteId); + const getFilters = () => this.getCourseModulesContexts(courseId, siteId); return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); } else if (contextLevel == 'course') { // 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); - } 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. - const getFilters = this.getBlocksContexts.bind(this, options.courseId, siteId); + const getFilters = () => this.getBlocksContexts(courseId, siteId); return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); } diff --git a/src/core/features/grades/services/handlers/course-option.ts b/src/core/features/grades/services/handlers/course-option.ts index 7c9049339..f701608de 100644 --- a/src/core/features/grades/services/handlers/course-option.ts +++ b/src/core/features/grades/services/handlers/course-option.ts @@ -19,8 +19,7 @@ import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData, } from '@features/course/services/course-options-delegate'; -import { CoreCourses, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; -import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper'; +import { CoreCourseAnyCourseData, CoreCourses, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { makeSingleton } from '@singletons'; import { CoreGrades } from '../grades'; @@ -34,11 +33,7 @@ export class CoreGradesCourseOptionHandlerService implements CoreCourseOptionsHa priority = 400; /** - * Should invalidate the data to determine if the handler is enabled for a certain course. - * - * @param courseId The course ID. - * @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions. - * @return Promise resolved when done. + * @inheritdoc */ invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise { if (navOptions && navOptions.grades !== undefined) { @@ -50,21 +45,14 @@ export class CoreGradesCourseOptionHandlerService implements CoreCourseOptionsHa } /** - * Check if the handler is enabled on a site level. - * - * @return Whether or not the handler is enabled on a site level. + * @inheritdoc */ async isEnabled(): Promise { return true; } /** - * Whether or not the handler is enabled for a certain course. - * - * @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. + * @inheritdoc */ isEnabledForCourse( 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. - * - * @param course The course. - * @return Promise resolved when done. + * @inheritdoc */ - async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise { + async prefetch(course: CoreCourseAnyCourseData): Promise { try { await CoreGrades.getCourseGradesTable(course.id, undefined, undefined, true); } catch (error) { diff --git a/src/core/features/mainmenu/pages/menu/menu.ts b/src/core/features/mainmenu/pages/menu/menu.ts index bedf32321..bda11ff26 100644 --- a/src/core/features/mainmenu/pages/menu/menu.ts +++ b/src/core/features/mainmenu/pages/menu/menu.ts @@ -92,7 +92,7 @@ export class CoreMainMenuPage implements OnInit, OnDestroy { tabAction: CoreMainMenuRoleTab; constructor() { - this.backButtonFunction = this.backButtonClicked.bind(this); + this.backButtonFunction = (event) => this.backButtonClicked(event); this.tabAction = new CoreMainMenuRoleTab(this); this.logger = CoreLogger.getInstance('CoreMainMenuPage'); diff --git a/src/core/features/mainmenu/pages/more/more.ts b/src/core/features/mainmenu/pages/more/more.ts index f56521f7d..dd3eaf5e8 100644 --- a/src/core/features/mainmenu/pages/more/more.ts +++ b/src/core/features/mainmenu/pages/more/more.ts @@ -50,7 +50,7 @@ export class CoreMainMenuMorePage implements OnInit, OnDestroy { protected resizeListener?: CoreEventObserver; 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.customItems = await CoreMainMenu.getCustomMenuItems(); diff --git a/src/core/features/settings/services/settings-helper.ts b/src/core/features/settings/services/settings-helper.ts index 16404feae..ef82c822c 100644 --- a/src/core/features/settings/services/settings-helper.ts +++ b/src/core/features/settings/services/settings-helper.ts @@ -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, () => { // Reset color scheme settings. diff --git a/src/core/features/siteplugins/classes/handlers/course-option-handler.ts b/src/core/features/siteplugins/classes/handlers/course-option-handler.ts index 14d8c35fe..b6371dc46 100644 --- a/src/core/features/siteplugins/classes/handlers/course-option-handler.ts +++ b/src/core/features/siteplugins/classes/handlers/course-option-handler.ts @@ -19,8 +19,7 @@ import { CoreCourseOptionsHandlerData, CoreCourseOptionsMenuHandlerData, } from '@features/course/services/course-options-delegate'; -import { CoreCourseAnyCourseDataWithOptions } from '@features/courses/services/courses'; -import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper'; +import { CoreCourseAnyCourseData, CoreCourseAnyCourseDataWithOptions } from '@features/courses/services/courses'; import { CoreSitePlugins, CoreSitePluginsContent, @@ -107,7 +106,7 @@ export class CoreSitePluginsCourseOptionHandler extends CoreSitePluginsBaseHandl /** * @inheritdoc */ - prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise { + prefetch(course: CoreCourseAnyCourseData): Promise { const args = { courseid: course.id, }; diff --git a/src/core/features/siteplugins/classes/handlers/module-handler.ts b/src/core/features/siteplugins/classes/handlers/module-handler.ts index 01ae7b0c9..8eda44cbb 100644 --- a/src/core/features/siteplugins/classes/handlers/module-handler.ts +++ b/src/core/features/siteplugins/classes/handlers/module-handler.ts @@ -56,7 +56,7 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp if (initResult?.jsResult && initResult.jsResult.supportsFeature) { // 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); } } diff --git a/src/core/features/siteplugins/classes/handlers/module-prefetch-handler.ts b/src/core/features/siteplugins/classes/handlers/module-prefetch-handler.ts index 24e58be5a..2781d6901 100644 --- a/src/core/features/siteplugins/classes/handlers/module-prefetch-handler.ts +++ b/src/core/features/siteplugins/classes/handlers/module-prefetch-handler.ts @@ -58,7 +58,7 @@ export class CoreSitePluginsModulePrefetchHandler extends CoreCourseActivityPref return this.prefetchPackage( module, courseId, - this.downloadPrefetchPlugin.bind(this, module, courseId, false, dirPath, siteId), + (siteId) => this.downloadPrefetchPlugin(module, courseId, false, dirPath, siteId), siteId, ); } @@ -226,7 +226,7 @@ export class CoreSitePluginsModulePrefetchHandler extends CoreCourseActivityPref return this.prefetchPackage( module, courseId, - this.downloadPrefetchPlugin.bind(this, module, courseId, true, dirPath), + (siteId) => this.downloadPrefetchPlugin(module, courseId, true, dirPath, siteId), ); } diff --git a/src/core/features/siteplugins/components/plugin-content/plugin-content.ts b/src/core/features/siteplugins/components/plugin-content/plugin-content.ts index 1704e3cff..32c9da985 100644 --- a/src/core/features/siteplugins/components/plugin-content/plugin-content.ts +++ b/src/core/features/siteplugins/components/plugin-content/plugin-content.ts @@ -108,11 +108,13 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { 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. - this.jsData.fetchContent = this.fetchContent.bind(this); - this.jsData.openContent = this.openContent.bind(this); - this.jsData.refreshContent = this.refreshContent.bind(this); - this.jsData.updateContent = this.updateContent.bind(this); - this.jsData.updateModuleCourseContent = this.updateModuleCourseContent.bind(this); + this.jsData.fetchContent = refresh => this.fetchContent(refresh); + this.jsData.openContent = (title, args, component, method, jsData, preSets, ptrEnabled) => + this.openContent(title, args, component, method, jsData, preSets, ptrEnabled); + this.jsData.refreshContent = showSpinner => this.refreshContent(showSpinner); + 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 }); } catch (error) { diff --git a/src/core/features/siteplugins/services/siteplugins-helper.ts b/src/core/features/siteplugins/services/siteplugins-helper.ts index c036daacf..4fb648162 100644 --- a/src/core/features/siteplugins/services/siteplugins-helper.ts +++ b/src/core/features/siteplugins/services/siteplugins-helper.ts @@ -362,7 +362,7 @@ export class CoreSitePluginsHelperProvider { plugin.parsedHandlers = CoreTextUtils.parseJSON( plugin.handlers, 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.lang, null, - this.logger.error.bind(this.logger, 'Error parsing site plugin lang'), + error => this.logger.error('Error parsing site plugin lang', error), ); } diff --git a/src/core/features/siteplugins/services/siteplugins.ts b/src/core/features/siteplugins/services/siteplugins.ts index 567799359..7cbc8dcdc 100644 --- a/src/core/features/siteplugins/services/siteplugins.ts +++ b/src/core/features/siteplugins/services/siteplugins.ts @@ -468,7 +468,7 @@ export class CoreSitePluginsProvider { plugin.parsedHandlers = CoreTextUtils.parseJSON( plugin.handlers, null, - this.logger.error.bind(this.logger, 'Error parsing site plugin handlers'), + error => this.logger.error('Error parsing site plugin handlers', error), ); } diff --git a/src/core/features/user/services/handlers/course-option.ts b/src/core/features/user/services/handlers/course-option.ts index 37de80356..2d668ad66 100644 --- a/src/core/features/user/services/handlers/course-option.ts +++ b/src/core/features/user/services/handlers/course-option.ts @@ -19,8 +19,7 @@ import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData, } from '@features/course/services/course-options-delegate'; -import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; -import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper'; +import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { PARTICIPANTS_PAGE_NAME } from '@features/user/user.module'; import { makeSingleton } from '@singletons'; import { CoreUser } from '../user'; @@ -35,11 +34,7 @@ export class CoreUserCourseOptionHandlerService implements CoreCourseOptionsHand priority = 600; /** - * Should invalidate the data to determine if the handler is enabled for a certain course. - * - * @param courseId The course ID. - * @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions. - * @return Promise resolved when done. + * @inheritdoc */ invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise { if (navOptions && navOptions.participants !== undefined) { @@ -51,21 +46,14 @@ export class CoreUserCourseOptionHandlerService implements CoreCourseOptionsHand } /** - * Check if the handler is enabled on a site level. - * - * @return Whether or not the handler is enabled on a site level. + * @inheritdoc */ isEnabled(): Promise { return Promise.resolve(true); } /** - * Whether or not the handler is enabled for a certain course. - * - * @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. + * @inheritdoc */ isEnabledForCourse( 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. - * - * @param course The course. - * @return Promise resolved when done. + * @inheritdoc */ - async prefetch(course: CoreEnrolledCourseDataWithExtraInfoAndOptions): Promise { + async prefetch(course: CoreCourseAnyCourseData): Promise { let offset = 0; let canLoadMore = true; diff --git a/src/core/features/user/services/user-sync.ts b/src/core/features/user/services/user-sync.ts index a09fd892c..a541ed38b 100644 --- a/src/core/features/user/services/user-sync.ts +++ b/src/core/features/user/services/user-sync.ts @@ -41,7 +41,7 @@ export class CoreUserSyncProvider extends CoreSyncBaseProvider { * @return Promise resolved with warnings if sync is successful, rejected if sync fails. */ syncPreferences(siteId?: string): Promise { - return this.syncOnSites('all user preferences', this.syncSitePreferences.bind(this), siteId); + return this.syncOnSites('all user preferences', (siteId) => this.syncSitePreferences(siteId), siteId); } /** diff --git a/src/core/services/file.ts b/src/core/services/file.ts index 85580f311..7a8e59ca5 100644 --- a/src/core/services/file.ts +++ b/src/core/services/file.ts @@ -834,9 +834,9 @@ export class CoreFileProvider { return this.copyOrMoveExternalFile(from, to, copy); } - const moveCopyFn: MoveCopyFunction = copy ? - (isDir ? File.copyDir.bind(File.instance) : File.copyFile.bind(File.instance)) : - (isDir ? File.moveDir.bind(File.instance) : File.moveFile.bind(File.instance)); + const moveCopyFn: MoveCopyFunction = (...args) => copy ? + (isDir ? File.copyDir(...args) : File.copyFile(...args)) : + (isDir ? File.moveDir(...args) : File.moveFile(...args)); await this.init(); @@ -854,14 +854,16 @@ export class CoreFileProvider { try { const entry = await moveCopyFn(this.basePath, from, this.basePath, to); - return entry; + return entry; } catch (error) { // The copy can fail if the path has encoded characters. Try again if that's the case. const decodedFrom = decodeURI(from); const decodedTo = decodeURI(to); if (from != decodedFrom || to != decodedTo) { - return moveCopyFn(this.basePath, decodedFrom, this.basePath, decodedTo); + const entry = await moveCopyFn(this.basePath, decodedFrom, this.basePath, decodedTo); + + return entry; } else { return Promise.reject(error); } @@ -1307,4 +1309,4 @@ export class CoreFileProvider { export const CoreFile = makeSingleton(CoreFileProvider); -type MoveCopyFunction = (path: string, dirName: string, newPath: string, newDirName: string) => Promise; +type MoveCopyFunction = (path: string, name: string, newPath: string, newName: string) => Promise; diff --git a/src/core/services/lang.ts b/src/core/services/lang.ts index ff281a7b2..2773d8d48 100644 --- a/src/core/services/lang.ts +++ b/src/core/services/lang.ts @@ -293,7 +293,7 @@ export class CoreLangProvider { * @return Translated month names. */ 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. */ 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. */ 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. */ getDayShortNames(): string[] { - return moment.weekdaysShort().map(this.capitalize.bind(this)); + return moment.weekdaysShort().map(weekDay => this.capitalize(weekDay)); } /** diff --git a/src/core/services/screen.ts b/src/core/services/screen.ts index 148eac683..f23b0b4f9 100644 --- a/src/core/services/screen.ts +++ b/src/core/services/screen.ts @@ -74,7 +74,7 @@ export class CoreScreenService { }), {} as Record)); this._layoutObservable = this.breakpointsObservable.pipe( - map(this.calculateLayout.bind(this)), + map(breakpoints => this.calculateLayout(breakpoints)), distinctUntilChanged(), ); } diff --git a/src/core/services/utils/iframe.ts b/src/core/services/utils/iframe.ts index 56c7d07de..5637d72ca 100644 --- a/src/core/services/utils/iframe.ts +++ b/src/core/services/utils/iframe.ts @@ -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. 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. }); @@ -468,7 +468,7 @@ export class CoreIframeUtilsProvider { */ protected async linkClicked( link: CoreIframeHTMLAnchorElement | {href: string; target?: string; originalHref?: string}, - element?: HTMLFrameElement | HTMLObjectElement, + element?: CoreFrameElement, event?: Event, ): Promise { if (event && event.defaultPrevented) { @@ -554,7 +554,7 @@ export class CoreIframeUtilsProvider { userScriptWindow.WKUserScript?.addScript({ id: 'CoreIframeUtilsLinksScript', file: linksPath }); // Handle post messages received by iframes. - window.addEventListener('message', this.handleIframeMessage.bind(this)); + window.addEventListener('message', (event) => this.handleIframeMessage(event)); } /** diff --git a/src/core/services/utils/utils.ts b/src/core/services/utils/utils.ts index c8f588d94..23f51f9e1 100644 --- a/src/core/services/utils/utils.ts +++ b/src/core/services/utils/utils.ts @@ -488,7 +488,7 @@ export class CoreUtilsProvider { */ async filterEnabledSites

( siteIds: string[], - isEnabledFn: (siteId, ...args: P) => boolean | Promise, + isEnabledFn: (siteId: string, ...args: P) => boolean | Promise, checkAll?: boolean, ...args: P ): Promise { diff --git a/src/core/services/ws.ts b/src/core/services/ws.ts index 9f83fd9e1..4c96e8a6c 100644 --- a/src/core/services/ws.ts +++ b/src/core/services/ws.ts @@ -908,7 +908,7 @@ export class CoreWSProvider { const data = CoreTextUtils.parseJSON( success.response, 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) { diff --git a/src/core/singletons/logger.ts b/src/core/singletons/logger.ts index 727c3f9bf..e7520c050 100644 --- a/src/core/singletons/logger.ts +++ b/src/core/singletons/logger.ts @@ -86,15 +86,15 @@ export class CoreLogger { return new CoreLogger( // 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 - CoreLogger.prepareLogFn(console.info.bind(console), className), + CoreLogger.prepareLogFn((...data) => console.info(...data), className), // 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 - CoreLogger.prepareLogFn(console.debug.bind(console), className), + CoreLogger.prepareLogFn((...data) => console.debug(...data), className), // eslint-disable-next-line no-console - CoreLogger.prepareLogFn(console.error.bind(console), className), + CoreLogger.prepareLogFn((...data) => console.error(...data), className), ); }