diff --git a/src/addons/mod/forum/components/index/index.ts b/src/addons/mod/forum/components/index/index.ts index a9c6fc7e8..33c844ddf 100644 --- a/src/addons/mod/forum/components/index/index.ts +++ b/src/addons/mod/forum/components/index/index.ts @@ -48,7 +48,6 @@ import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { AddonModForumDiscussionOptionsMenuComponent } from '../discussion-options-menu/discussion-options-menu'; import { AddonModForumSortOrderSelectorComponent } from '../sort-order-selector/sort-order-selector'; import { CoreScreen } from '@services/screen'; -import { CoreArray } from '@singletons/array'; import { AddonModForumPrefetchHandler } from '../../services/handlers/prefetch'; import { AddonModForumModuleHandlerService } from '../../services/handlers/module'; import { CoreRatingProvider } from '@features/rating/services/rating'; @@ -561,7 +560,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom } if (this.discussions?.getSource().isOnlineDiscussion(disc)) { - return CoreArray.contains(newDiscussionData.discussionIds ?? [], disc.discussion); + return (newDiscussionData.discussionIds ?? []).includes(disc.discussion); } return false; diff --git a/src/addons/mod/forum/services/forum-sync.ts b/src/addons/mod/forum/services/forum-sync.ts index f033e9d22..f522dc34f 100644 --- a/src/addons/mod/forum/services/forum-sync.ts +++ b/src/addons/mod/forum/services/forum-sync.ts @@ -24,7 +24,6 @@ import { CoreSites } from '@services/sites'; import { CoreSync } from '@services/sync'; import { CoreUtils } from '@services/utils/utils'; import { makeSingleton, Translate } from '@singletons'; -import { CoreArray } from '@singletons/array'; import { CoreEvents } from '@singletons/events'; import { AddonModForum, @@ -90,7 +89,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide // Do not sync same forum twice. const syncedForumIds: number[] = []; const promises = discussions.map(async discussion => { - if (CoreArray.contains(syncedForumIds, discussion.forumid)) { + if (syncedForumIds.includes(discussion.forumid)) { return; } @@ -123,7 +122,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide // Do not sync same discussion twice. const syncedDiscussionIds: number[] = []; const promises = replies.map(async reply => { - if (CoreArray.contains(syncedDiscussionIds, reply.discussionid)) { + if (syncedDiscussionIds.includes(reply.discussionid)) { return; } diff --git a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts index 0f2e8a215..6a459959d 100644 --- a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts +++ b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts @@ -126,7 +126,7 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy try { await Promise.all(deletedCourseIds.map((courseId) => CoreCourseHelper.deleteCourseFiles(courseId))); - this.setDownloadedCourses(this.downloadedCourses.filter((course) => !CoreArray.contains(deletedCourseIds, course.id))); + this.setDownloadedCourses(this.downloadedCourses.filter((course) => !deletedCourseIds.includes(course.id))); } catch (error) { CoreDomUtils.showErrorModalDefault(error, Translate.instant('core.errordeletefile')); } finally { diff --git a/src/core/services/ws.ts b/src/core/services/ws.ts index 9d9e270de..38eb55151 100644 --- a/src/core/services/ws.ts +++ b/src/core/services/ws.ts @@ -31,7 +31,6 @@ import { CoreConstants } from '@/core/constants'; import { CoreError } from '@classes/errors/error'; import { CoreInterceptor } from '@classes/interceptor'; import { makeSingleton, Translate, FileTransfer, Http, NativeHttp } from '@singletons'; -import { CoreArray } from '@singletons/array'; import { CoreLogger } from '@singletons/logger'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreAjaxError } from '@classes/errors/ajaxerror'; @@ -282,7 +281,7 @@ export class CoreWSProvider { extension = CoreMimetypeUtils.getFileExtension(path) || ''; // Google Drive extensions will be considered invalid since Moodle usually converts them. - if (!extension || CoreArray.contains(['gdoc', 'gsheet', 'gslides', 'gdraw', 'php'], extension)) { + if (!extension || ['gdoc', 'gsheet', 'gslides', 'gdraw', 'php'].includes(extension)) { // Not valid, get the file's mimetype. const mimetype = await this.getRemoteFileMimeType(url); diff --git a/src/core/singletons/array.ts b/src/core/singletons/array.ts index 03a6ad4d3..5ed86de9b 100644 --- a/src/core/singletons/array.ts +++ b/src/core/singletons/array.ts @@ -23,8 +23,12 @@ export class CoreArray { * @param arr Array. * @param item Item. * @return Whether item is within the array. + * @deprecated since 4.1. Use arr.includes() instead. */ static contains(arr: T[], item: T): boolean { + // eslint-disable-next-line no-console + console.warn('CoreArray.contains is deprecated and will be removed soon. Please use array \'includes\' instead.'); + return arr.indexOf(item) !== -1; }