forked from EVOgeek/Vmeda.Online
		
	MOBILE-4069 singletons: Deprecate CoreArray.contains
This commit is contained in:
		
							parent
							
								
									92aac833a3
								
							
						
					
					
						commit
						d5b6f557a0
					
				| @ -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; | ||||
|  | ||||
| @ -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; | ||||
|                 } | ||||
| 
 | ||||
|  | ||||
| @ -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 { | ||||
|  | ||||
| @ -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); | ||||
| 
 | ||||
|  | ||||
| @ -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<T>(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; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user