From 2e1626dcfbbaa028526a3f21da6d6ecb6145aaec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 3 Jul 2024 16:23:00 +0200 Subject: [PATCH] MOBILE-4594 chore: Remove deprecated code on 4.1 and 4.0 --- .../calendar/services/calendar-helper.ts | 21 --- src/addons/calendar/services/calendar.ts | 121 ------------------ .../notifications/services/notifications.ts | 66 ---------- src/core/classes/errors/siteerror.ts | 2 +- src/core/classes/promised-value.ts | 8 -- src/core/classes/sites/site.ts | 53 -------- src/core/features/compile/services/compile.ts | 10 +- .../module-description/module-description.ts | 3 +- .../courses/components/components.module.ts | 5 - .../core-courses-course-progress.html | 2 - .../course-progress/course-progress.ts | 42 ------ .../settings/services/settings-helper.ts | 2 +- src/core/services/app.ts | 73 +---------- src/core/services/file.ts | 11 -- src/core/services/local-notifications.ts | 10 -- src/core/services/network.ts | 10 +- src/core/services/utils/dom.ts | 5 - src/core/services/utils/time.ts | 13 -- src/core/services/utils/utils.ts | 10 -- src/core/singletons/array.ts | 15 --- src/core/singletons/components-registry.ts | 94 -------------- src/core/singletons/dom.ts | 14 -- src/core/singletons/html-classes.ts | 8 +- src/core/singletons/text.ts | 14 -- 24 files changed, 20 insertions(+), 592 deletions(-) delete mode 100644 src/core/features/courses/components/course-progress/core-courses-course-progress.html delete mode 100644 src/core/features/courses/components/course-progress/course-progress.ts delete mode 100644 src/core/singletons/components-registry.ts diff --git a/src/addons/calendar/services/calendar-helper.ts b/src/addons/calendar/services/calendar-helper.ts index be7426e56..7f32071b2 100644 --- a/src/addons/calendar/services/calendar-helper.ts +++ b/src/addons/calendar/services/calendar-helper.ts @@ -294,27 +294,6 @@ export class AddonCalendarHelperProvider { } } - /** - * Format reminders, adding calculated data. - * - * @param reminders Reminders. - * @param timestart Event timestart. - * @param siteId Site ID. - * @returns Formatted reminders. - * @deprecated since 4.1 Use AddonCalendarHelper.getEventReminders. - */ - async formatReminders( - reminders: { eventid: number }[], - timestart: number, - siteId?: string, - ): Promise { - if (!reminders.length) { - return []; - } - - return AddonCalendarHelper.getEventReminders(reminders[0].eventid, timestart, siteId); - } - /** * Format reminders, adding calculated data. * diff --git a/src/addons/calendar/services/calendar.ts b/src/addons/calendar/services/calendar.ts index 0b0633094..db0bc8437 100644 --- a/src/addons/calendar/services/calendar.ts +++ b/src/addons/calendar/services/calendar.ts @@ -45,10 +45,7 @@ import { CoreReminders, CoreRemindersPushNotificationData, CoreRemindersService, - CoreRemindersUnits, - CoreReminderValueAndUnit, } from '@features/reminders/services/reminders'; -import { CoreReminderDBRecord } from '@features/reminders/services/database/reminders'; import { CoreEvents } from '@singletons/events'; import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; import { ADDON_CALENDAR_COMPONENT } from '../constants'; @@ -66,18 +63,6 @@ export enum AddonCalendarEventType { USER = 'user', } -/** - * Units to set a reminder. - * - * @deprecated since 4.1 Use CoreReminderUnits instead. - */ -export enum AddonCalendarReminderUnits { - MINUTE = CoreConstants.SECONDS_MINUTE, - HOUR = CoreConstants.SECONDS_HOUR, - DAY = CoreConstants.SECONDS_DAY, - WEEK = CoreConstants.SECONDS_WEEK, -} - declare module '@singletons/events' { /** @@ -178,17 +163,6 @@ export class AddonCalendarProvider { return !!site?.isVersionGreaterEqualThan('3.7.1'); } - /** - * Given a number of seconds, convert it to a unit&value format compatible with reminders. - * - * @param seconds Number of seconds. - * @returns Value and unit. - * @deprecated since 4.1 Use CoreRemindersService.convertSecondsToValueAndUnit instead. - */ - static convertSecondsToValueAndUnit(seconds: number): CoreReminderValueAndUnit { - return CoreRemindersService.convertSecondsToValueAndUnit(seconds); - } - /** * Delete an event. * @@ -592,17 +566,6 @@ export class AddonCalendarProvider { return CoreTimeUtils.userDate(time, 'core.strftimedayshort'); } - /** - * Get the configured default notification time. - * - * @param siteId ID of the site. If not defined, use current site. - * @returns Promise resolved with the default time (in seconds). - * @deprecated since 4.1 Use CoreReminders.getDefaultNotificationTime instead. - */ - async getDefaultNotificationTime(siteId?: string): Promise { - return CoreReminders.getDefaultNotificationTime(siteId); - } - /** * Get a calendar event. If the server request fails and data is not cached, try to get it from local DB. * @@ -780,18 +743,6 @@ export class AddonCalendarProvider { return event.eventtype; } - /** - * Remove an event reminder and cancel the notification. - * - * @param id Reminder ID. - * @param siteId ID of the site the event belongs to. If not defined, use current site. - * @returns Promise resolved when the notification is updated. - * @deprecated since 4.1. Use CoreReminders.removeReminder instead. - */ - async deleteEventReminder(id: number, siteId?: string): Promise { - await CoreReminders.removeReminder(id, siteId); - } - /** * Get calendar events for a certain day. * @@ -876,21 +827,6 @@ export class AddonCalendarProvider { (categoryId ? categoryId : ''); } - /** - * Get a calendar reminders from local Db. - * - * @param eventId Event ID. - * @param siteId ID of the site the event belongs to. If not defined, use current site. - * @returns Promise resolved when the event data is retrieved. - * @deprecated since 4.1. Use CoreReminders.getReminders instead. - */ - async getEventReminders(eventId: number, siteId?: string): Promise { - return CoreReminders.getReminders({ - instanceId: eventId, - component: ADDON_CALENDAR_COMPONENT, - }, siteId); - } - /** * Get the events in a certain period. The period is calculated like this: * start time: now + daysToStart @@ -1089,19 +1025,6 @@ export class AddonCalendarProvider { (categoryId ? categoryId : ''); } - /** - * Given a value and a unit, return the translated label. - * - * @param value Value. - * @param unit Unit. - * @param addDefaultLabel Whether to add the "Default" text. - * @returns Translated label. - * @deprecated since 4.1 Use CoreReminders.getUnitValueLabel instead. - */ - getUnitValueLabel(value: number, unit: CoreRemindersUnits, addDefaultLabel = false): string { - return CoreReminders.getUnitValueLabel(value, unit, addDefaultLabel); - } - /** * Get upcoming calendar events. * @@ -1378,16 +1301,6 @@ export class AddonCalendarProvider { return this.isCalendarDisabledInSite(site); } - /** - * Get the next events for all the sites and schedules their notifications. - * - * @returns Promise resolved when done. - * @deprecated since 4.1 Use AddonCalendar.updateAllSitesEventReminders. - */ - async scheduleAllSitesEventsNotifications(): Promise { - await AddonCalendar.updateAllSitesEventReminders(); - } - /** * Get the next events for all the sites and updates their reminders. */ @@ -1415,21 +1328,6 @@ export class AddonCalendarProvider { await this.getEventsList(undefined, undefined, undefined, siteId); } - /** - * Get the next events for all the sites and schedules their notifications. - * - * @returns Promise resolved when done. - * @deprecated since 4.1. No replacement for that function. - */ - async scheduleEventsNotifications( - events: ({ id: number; timestart: number; timeduration: number; name: string})[], - siteId?: string, - ): Promise { - siteId = siteId || CoreSites.getCurrentSiteId(); - - await AddonCalendar.updateEventsReminders(events, siteId); - } - /** * Schedules the notifications for a list of events. * If an event notification time is 0, cancel its scheduled notification (if any). @@ -1470,18 +1368,6 @@ export class AddonCalendarProvider { })); } - /** - * Set the default notification time. - * - * @param time New default time. - * @param siteId ID of the site. If not defined, use current site. - * @returns Promise resolved when stored. - * @deprecated since 4.1 Use CoreReminders.setDefaultNotificationTime. - */ - async setDefaultNotificationTime(time: number, siteId?: string): Promise { - await CoreReminders.setDefaultNotificationTime(time, siteId); - } - /** * Store an event in local DB as it is. * @@ -2203,13 +2089,6 @@ export type AddonCalendarUpdatedEventEvent = { sent?: boolean; }; -/** - * Value and unit for reminders. - * - * @deprecated since 4.1, use CoreReminderValueAndUnit instead. - */ -export type AddonCalendarValueAndUnit = CoreReminderValueAndUnit; - /** * Options to pass to submit event. */ diff --git a/src/addons/notifications/services/notifications.ts b/src/addons/notifications/services/notifications.ts index c25c81fa1..49ed2a791 100644 --- a/src/addons/notifications/services/notifications.ts +++ b/src/addons/notifications/services/notifications.ts @@ -209,72 +209,6 @@ export class AddonNotificationsProvider { return ROOT_CACHE_KEY + 'list'; } - /** - * Get some notifications. - * - * @param notifications Current list of loaded notifications. It's used to calculate the offset. - * @param options Other options. - * @returns Promise resolved with notifications and if can load more. - * @deprecated since 4.1. Use getNotificationsWithStatus instead. - */ - async getNotifications( - notifications: AddonNotificationsNotificationMessageFormatted[], - options?: AddonNotificationsGetNotificationsOptions, - ): Promise<{notifications: AddonNotificationsNotificationMessageFormatted[]; canLoadMore: boolean}> { - - notifications = notifications || []; - options = options || {}; - options.limit = options.limit || AddonNotificationsProvider.LIST_LIMIT; - options.siteId = options.siteId || CoreSites.getCurrentSiteId(); - let newNotifications: AddonNotificationsNotificationMessageFormatted[]; - - // Request 1 more notification so we can know if there are more notifications. - const originalLimit = options.limit; - options.limit = options.limit + 1; - - const site = await CoreSites.getSite(options.siteId); - - if (site.isVersionGreaterEqualThan('4.0')) { - // In 4.0 the app can request read and unread at the same time. - options.offset = notifications.length; - newNotifications = await this.getNotificationsWithStatus( - AddonNotificationsGetReadType.BOTH, - options, - ); - } else { - // We need 2 calls, one for read and the other one for unread. - options.offset = notifications.reduce((total, current) => total + (current.read ? 0 : 1), 0); - - const unread = await this.getNotificationsWithStatus(AddonNotificationsGetReadType.UNREAD, options); - - newNotifications = unread; - - if (unread.length < options.limit) { - // Limit not reached. Get read notifications until reach the limit. - const readOptions = { - ...options, - offset: notifications.length - options.offset, - limit: options.limit - unread.length, - }; - - try { - const read = await this.getNotificationsWithStatus(AddonNotificationsGetReadType.READ, readOptions); - - newNotifications = unread.concat(read); - } catch (error) { - if (unread.length <= 0) { - throw error; - } - } - } - } - - return { - notifications: newNotifications.slice(0, originalLimit), - canLoadMore: newNotifications.length > originalLimit, - }; - } - /** * Get notifications from site. * diff --git a/src/core/classes/errors/siteerror.ts b/src/core/classes/errors/siteerror.ts index 3eed531e6..9e1f2f569 100644 --- a/src/core/classes/errors/siteerror.ts +++ b/src/core/classes/errors/siteerror.ts @@ -31,7 +31,7 @@ export class CoreSiteError extends CoreError { } /** - * @deprecated This getter should not be called directly, but it's defined for backwards compatibility with many + * @deprecated since 4.4. This getter should not be called directly, but it's defined for backwards compatibility with many * parts of the code that type errors as any and use it. We cannot rename those because the errors could also be * CoreWSError instances which do have an "errorcode" property. * diff --git a/src/core/classes/promised-value.ts b/src/core/classes/promised-value.ts index 24f173224..d437e841b 100644 --- a/src/core/classes/promised-value.ts +++ b/src/core/classes/promised-value.ts @@ -55,14 +55,6 @@ export class CorePromisedValue extends CorePromise { this.rejectPromise = rejectPromise; } - /** - * @returns Promise. - * @deprecated since 4.1. The instance can be directly used as a promise. - */ - get promise(): Promise { - return this; - } - get value(): T | null { return this.resolvedValue ?? null; } diff --git a/src/core/classes/sites/site.ts b/src/core/classes/sites/site.ts index 2a8af678a..80e6c07e3 100644 --- a/src/core/classes/sites/site.ts +++ b/src/core/classes/sites/site.ts @@ -475,23 +475,6 @@ export class CoreSite extends CoreAuthenticatedSite { await this.openWithAutoLogin(false, url, options, alertMessage); } - /** - * Open a URL in browser using auto-login in the Moodle site if available and the URL belongs to the site. - * - * @param url The URL to open. - * @param alertMessage If defined, an alert will be shown before opening the browser. - * @param options Other options. - * @returns Promise resolved when done, rejected otherwise. - * @deprecated since 4.1. Use openInBrowserWithAutoLogin instead, now it always checks that URL belongs to same site. - */ - async openInBrowserWithAutoLoginIfSameSite( - url: string, - alertMessage?: string, - options: CoreUtilsOpenInBrowserOptions = {}, - ): Promise { - return this.openInBrowserWithAutoLogin(url, alertMessage, options); - } - /** * Open a URL in inappbrowser using auto-login in the Moodle site if available. * @@ -506,23 +489,6 @@ export class CoreSite extends CoreAuthenticatedSite { return iabInstance; } - /** - * Open a URL in inappbrowser using auto-login in the Moodle site if available and the URL belongs to the site. - * - * @param url The URL to open. - * @param options Override default options passed to inappbrowser. - * @param alertMessage If defined, an alert will be shown before opening the inappbrowser. - * @returns Promise resolved when done. - * @deprecated since 4.1. Use openInAppWithAutoLogin instead, now it always checks that URL belongs to same site. - */ - async openInAppWithAutoLoginIfSameSite( - url: string, - options?: InAppBrowserOptions, - alertMessage?: string, - ): Promise { - return this.openInAppWithAutoLogin(url, options, alertMessage); - } - /** * Open a URL in browser or InAppBrowser using auto-login in the Moodle site if available. * @@ -575,25 +541,6 @@ export class CoreSite extends CoreAuthenticatedSite { } } - /** - * Open a URL in browser or InAppBrowser using auto-login in the Moodle site if available and the URL belongs to the site. - * - * @param inApp True to open it in InAppBrowser, false to open in browser. - * @param url The URL to open. - * @param options Override default options passed to inappbrowser. - * @param alertMessage If defined, an alert will be shown before opening the browser/inappbrowser. - * @returns Promise resolved when done. Resolve param is returned only if inApp=true. - * @deprecated since 4.1. Use openWithAutoLogin instead, now it always checks that URL belongs to same site. - */ - async openWithAutoLoginIfSameSite( - inApp: boolean, - url: string, - options: InAppBrowserOptions & CoreUtilsOpenInBrowserOptions = {}, - alertMessage?: string, - ): Promise { - return this.openWithAutoLogin(inApp, url, options, alertMessage); - } - /** * Get the config of this site. * It is recommended to use getStoredConfig instead since it's faster and doesn't use network. diff --git a/src/core/features/compile/services/compile.ts b/src/core/features/compile/services/compile.ts index 63849d3d0..b253c6149 100644 --- a/src/core/features/compile/services/compile.ts +++ b/src/core/features/compile/services/compile.ts @@ -77,7 +77,6 @@ import { Md5 } from 'ts-md5/dist/md5'; // Import core classes that can be useful for site plugins. import { CoreSyncBaseProvider } from '@classes/base-sync'; import { CoreArray } from '@singletons/array'; -import { CoreComponentsRegistry } from '@singletons/components-registry'; import { CoreDirectivesRegistry } from '@singletons/directives-registry'; import { CoreDom } from '@singletons/dom'; import { CoreForms } from '@singletons/form'; @@ -295,12 +294,13 @@ export class CoreCompileProvider { instance['CoreLoggerProvider'] = CoreLogger; instance['moment'] = moment; instance['Md5'] = Md5; - instance['Network'] = CoreNetwork.instance; // @deprecated since 4.1, plugins should use CoreNetwork instead. - instance['Platform'] = CorePlatform.instance; // @deprecated since 4.1, plugins should use CorePlatform instead. + /** + * @deprecated since 4.1, plugins should use CoreNetwork instead. + * Keeping this a bit more to avoid plugins breaking. + */ + instance['Network'] = CoreNetwork.instance; instance['CoreSyncBaseProvider'] = CoreSyncBaseProvider; instance['CoreArray'] = CoreArray; - // eslint-disable-next-line deprecation/deprecation - instance['CoreComponentsRegistry'] = CoreComponentsRegistry; instance['CoreDirectivesRegistry'] = CoreDirectivesRegistry; instance['CoreNetwork'] = CoreNetwork.instance; instance['CorePlatform'] = CorePlatform.instance; diff --git a/src/core/features/course/components/module-description/module-description.ts b/src/core/features/course/components/module-description/module-description.ts index d0bb74b58..738e89f9d 100644 --- a/src/core/features/course/components/module-description/module-description.ts +++ b/src/core/features/course/components/module-description/module-description.ts @@ -31,7 +31,8 @@ import { Component, HostBinding, Input } from '@angular/core'; * * * - * @deprecated since 4.0 use core-course-module-info + * @deprecated since 4.0 use core-course-module-info instead. + * Keeping this a bit more to avoid plugins breaking. */ @Component({ selector: 'core-course-module-description', diff --git a/src/core/features/courses/components/components.module.ts b/src/core/features/courses/components/components.module.ts index 591dc709d..a4444767f 100644 --- a/src/core/features/courses/components/components.module.ts +++ b/src/core/features/courses/components/components.module.ts @@ -16,14 +16,11 @@ import { NgModule } from '@angular/core'; import { CoreSharedModule } from '@/core/shared.module'; import { CoreCoursesCourseListItemComponent } from './course-list-item/course-list-item'; -import { CoreCoursesCourseProgressComponent } from './course-progress/course-progress'; import { CoreCoursesCourseOptionsMenuComponent } from './course-options-menu/course-options-menu'; @NgModule({ declarations: [ CoreCoursesCourseListItemComponent, - // eslint-disable-next-line deprecation/deprecation - CoreCoursesCourseProgressComponent, CoreCoursesCourseOptionsMenuComponent, ], imports: [ @@ -31,8 +28,6 @@ import { CoreCoursesCourseOptionsMenuComponent } from './course-options-menu/cou ], exports: [ CoreCoursesCourseListItemComponent, - // eslint-disable-next-line deprecation/deprecation - CoreCoursesCourseProgressComponent, CoreCoursesCourseOptionsMenuComponent, ], }) diff --git a/src/core/features/courses/components/course-progress/core-courses-course-progress.html b/src/core/features/courses/components/course-progress/core-courses-course-progress.html deleted file mode 100644 index 94f024f2c..000000000 --- a/src/core/features/courses/components/course-progress/core-courses-course-progress.html +++ /dev/null @@ -1,2 +0,0 @@ - diff --git a/src/core/features/courses/components/course-progress/course-progress.ts b/src/core/features/courses/components/course-progress/course-progress.ts deleted file mode 100644 index 463456237..000000000 --- a/src/core/features/courses/components/course-progress/course-progress.ts +++ /dev/null @@ -1,42 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Component, HostBinding, Input } from '@angular/core'; -import { CoreCourseListItem } from '@features/courses/services/courses'; - -/** - * This component is meant to display a course for a list of courses with progress. - * - * Example usage: - * - * - * - * - * @deprecated since 4.0. Use core-courses-course-list-item instead. - */ -@Component({ - selector: 'core-courses-course-progress', - templateUrl: 'core-courses-course-progress.html', -}) -export class CoreCoursesCourseProgressComponent { - - @Input() course!: CoreCourseListItem; // The course to render. - @Input() showAll = false; // If true, will show all actions, options, star and progress. - @Input() showDownload = true; // If true, will show download button. Only works if the options menu is not shown. - - @HostBinding('class.deprecated') get isDeprecated(): boolean { - return true; - } - -} diff --git a/src/core/features/settings/services/settings-helper.ts b/src/core/features/settings/services/settings-helper.ts index 483e28c7c..47444868b 100644 --- a/src/core/features/settings/services/settings-helper.ts +++ b/src/core/features/settings/services/settings-helper.ts @@ -437,7 +437,7 @@ export class CoreSettingsHelperProvider { const isDark = CoreDomUtils.hasModeClass('dark'); if (isDark !== enable) { - CoreDomUtils.toggleModeClass('dark', enable, { includeLegacy: true }); + CoreDomUtils.toggleModeClass('dark', enable); this.darkModeObservable.next(enable); CoreApp.setSystemUIColors(); diff --git a/src/core/services/app.ts b/src/core/services/app.ts index e980222b2..88031995f 100644 --- a/src/core/services/app.ts +++ b/src/core/services/app.ts @@ -30,9 +30,9 @@ import { CoreDatabaseTable } from '@classes/database/database-table'; import { CorePromisedValue } from '@classes/promised-value'; import { Subscription } from 'rxjs'; import { CorePlatform } from '@services/platform'; -import { CoreNetwork, CoreNetworkConnection } from '@services/network'; import { CoreMainMenuProvider } from '@features/mainmenu/services/mainmenu'; import { CoreKeyboard } from '@singletons/keyboard'; +import { CoreNetwork } from './network'; /** * Factory to provide some global functionalities, like access to the global app database. @@ -210,36 +210,6 @@ export class CoreAppProvider { return storesConfig.default; } - /** - * Get platform major version number. - * - * @returns The platform major number. - * @deprecated since 4.1.1. Use CorePlatform.getPlatformMajorVersion instead. - */ - getPlatformMajorVersion(): number { - return CorePlatform.getPlatformMajorVersion(); - } - - /** - * Checks if the app is running in an Android mobile or tablet device. - * - * @returns Whether the app is running in an Android mobile or tablet device. - * @deprecated since 4.1.1. Use CorePlatform.isAndroid instead. - */ - isAndroid(): boolean { - return CorePlatform.isAndroid(); - } - - /** - * Checks if the app is running in an iOS mobile or tablet device. - * - * @returns Whether the app is running in an iOS mobile or tablet device. - * @deprecated since 4.1.1. Use CorePlatform.isIOS instead. - */ - isIOS(): boolean { - return CorePlatform.isIOS(); - } - /** * Check if the keyboard is closing. * @@ -270,16 +240,6 @@ export class CoreAppProvider { return CoreKeyboard.isKeyboardVisible(); } - /** - * Checks if the app is running in a mobile or tablet device (Cordova). - * - * @returns Whether the app is running in a mobile or tablet device. - * @deprecated since 4.1. Use CorePlatform instead. - */ - isMobile(): boolean { - return CorePlatform.isMobile(); - } - /** * Checks if the current window is wider than a mobile. * @@ -294,31 +254,12 @@ export class CoreAppProvider { * * @returns Whether the app is online. * @deprecated since 4.1. Use CoreNetwork instead. + * Keeping this a bit more to avoid plugins breaking. */ isOnline(): boolean { return CoreNetwork.isOnline(); } - /** - * Check if device uses a limited connection. - * - * @returns Whether the device uses a limited connection. - * @deprecated since 4.1. Use CoreNetwork instead. - */ - isNetworkAccessLimited(): boolean { - return CoreNetwork.isNetworkAccessLimited(); - } - - /** - * Check if device uses a wifi connection. - * - * @returns Whether the device uses a wifi connection. - * @deprecated since 4.1. Use CoreNetwork instead. - */ - isWifi(): boolean { - return CoreNetwork.isWifi(); - } - /** * Open the keyboard. * @@ -561,16 +502,6 @@ export class CoreAppProvider { StatusBar.backgroundColorByHexString(color); } - /** - * Set value of forceOffline flag. If true, the app will think the device is offline. - * - * @param value Value to set. - * @deprecated since 4.1. Use CoreNetwork.setForceConnectionMode instead. - */ - setForceOffline(value: boolean): void { - CoreNetwork.setForceConnectionMode(value ? CoreNetworkConnection.NONE : CoreNetworkConnection.WIFI); - } - /** * Get the installed version for the given schema. * diff --git a/src/core/services/file.ts b/src/core/services/file.ts index cf2f8f550..aa369f185 100644 --- a/src/core/services/file.ts +++ b/src/core/services/file.ts @@ -1015,17 +1015,6 @@ export class CoreFileProvider { return promise.then((entry) => this.getMetadata(entry)); } - /** - * Remove the starting slash of a path if it's there. E.g. '/sites/filepool' -> 'sites/filepool'. - * - * @param path Path. - * @returns Path without a slash in the first position. - * @deprecated since 4.1. Use CoreText.removeStartingSlash instead. - */ - removeStartingSlash(path: string): string { - return CoreText.removeStartingSlash(path); - } - /** * Convenience function to copy or move an external file. * diff --git a/src/core/services/local-notifications.ts b/src/core/services/local-notifications.ts index 6ce207f53..f297b21ce 100644 --- a/src/core/services/local-notifications.ts +++ b/src/core/services/local-notifications.ts @@ -429,16 +429,6 @@ export class CoreLocalNotificationsProvider { } } - /** - * Returns whether local notifications are available. - * - * @returns Whether local notifications are available. - * @deprecated since 4.1. It will always return true. - */ - isAvailable(): boolean { - return true; - } - /** * Returns whether local notifications plugin is available. * diff --git a/src/core/services/network.ts b/src/core/services/network.ts index d7206e0b6..3c8cc18f9 100644 --- a/src/core/services/network.ts +++ b/src/core/services/network.ts @@ -111,22 +111,22 @@ export class CoreNetworkService extends Network { const hadOfflineMessage = CoreDomUtils.hasModeClass('core-offline'); - CoreDomUtils.toggleModeClass('core-offline', !isOnline, { includeLegacy: true }); + CoreDomUtils.toggleModeClass('core-offline', !isOnline); if (isOnline && hadOfflineMessage) { - CoreDomUtils.toggleModeClass('core-online', true, { includeLegacy: true }); + CoreDomUtils.toggleModeClass('core-online', true); setTimeout(() => { - CoreDomUtils.toggleModeClass('core-online', false, { includeLegacy: true }); + CoreDomUtils.toggleModeClass('core-online', false); }, 3000); } else if (!isOnline) { - CoreDomUtils.toggleModeClass('core-online', false, { includeLegacy: true }); + CoreDomUtils.toggleModeClass('core-online', false); } }); }); const isOnline = this.isOnline(); - CoreDomUtils.toggleModeClass('core-offline', !isOnline, { includeLegacy: true }); + CoreDomUtils.toggleModeClass('core-offline', !isOnline); } /** diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index a1797cf7f..3ea323352 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -1790,17 +1790,12 @@ export class CoreDomUtilsProvider { * * @param className Class name. * @param enable Whether to add or remove the class. - * @param options Legacy options, deprecated since 4.1. */ toggleModeClass( className: string, enable = false, - options: { includeLegacy: boolean } = { includeLegacy: false }, ): void { document.documentElement.classList.toggle(className, enable); - - // @deprecated since 4.1. - document.body.classList.toggle(className, enable && options.includeLegacy); } } diff --git a/src/core/services/utils/time.ts b/src/core/services/utils/time.ts index 24cb2857c..b2992aeea 100644 --- a/src/core/services/utils/time.ts +++ b/src/core/services/utils/time.ts @@ -215,19 +215,6 @@ export class CoreTimeUtilsProvider { return isoString.substring(0, isoString.indexOf('.')); } - /** - * Convert a text into user timezone timestamp. - * - * @param date To convert to timestamp. - * @param applyOffset Whether to apply offset to date or not. - * @returns Converted timestamp. - * @deprecated since 4.1. Use moment(date).unix() instead. - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - convertToTimestamp(date: string, applyOffset?: boolean): number { - return moment(date).unix(); - } - /** * Return the localized ISO format (i.e DDMMYY) from the localized moment format. Useful for translations. * DO NOT USE this function for ion-datetime format. Moment escapes characters with [], but ion-datetime doesn't support it. diff --git a/src/core/services/utils/utils.ts b/src/core/services/utils/utils.ts index e2c4b89a4..5783ca169 100644 --- a/src/core/services/utils/utils.ts +++ b/src/core/services/utils/utils.ts @@ -1409,16 +1409,6 @@ export class CoreUtilsProvider { return Object.keys(enumeration).filter(k => Number.isNaN(+k)) as K[]; } - /** - * Create a deferred promise that can be resolved or rejected explicitly. - * - * @returns The deferred promise. - * @deprecated since 4.1. Use CorePromisedValue instead. - */ - promiseDefer(): CorePromisedValue { - return new CorePromisedValue(); - } - /** * Given a promise, returns true if it's rejected or false if it's resolved. * diff --git a/src/core/singletons/array.ts b/src/core/singletons/array.ts index 49f81195f..71e885cb7 100644 --- a/src/core/singletons/array.ts +++ b/src/core/singletons/array.ts @@ -17,21 +17,6 @@ */ export class CoreArray { - /** - * Check whether an array contains an item. - * - * @param arr Array. - * @param item Item. - * @returns 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; - } - /** * Flatten the first dimension of a multi-dimensional array. * diff --git a/src/core/singletons/components-registry.ts b/src/core/singletons/components-registry.ts deleted file mode 100644 index 092c66ee6..000000000 --- a/src/core/singletons/components-registry.ts +++ /dev/null @@ -1,94 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Component } from '@angular/core'; -import { AsyncDirective } from '@classes/async-directive'; -import { CoreDirectivesRegistry } from '@singletons/directives-registry'; - -/** - * Registry to keep track of component instances. - * - * @deprecated since 4.1.1. Use CoreDirectivesRegistry instead. - */ -export class CoreComponentsRegistry { - - /** - * Register a component instance. - * - * @param element Root element. - * @param instance Component instance. - */ - static register(element: Element, instance: unknown): void { - CoreDirectivesRegistry.register(element, instance); - } - - /** - * Resolve a component instance. - * - * @param element Root element. - * @param componentClass Component class. - * @returns Component instance. - */ - static resolve(element?: Element | null, componentClass?: ComponentConstructor): T | null { - return CoreDirectivesRegistry.resolve(element, componentClass); - } - - /** - * Get a component instances and fail if it cannot be resolved. - * - * @param element Root element. - * @param componentClass Component class. - * @returns Component instance. - */ - static require(element: Element, componentClass?: ComponentConstructor): T { - return CoreDirectivesRegistry.require(element, componentClass); - } - - /** - * Get a component instances and wait to be ready. - * - * @param element Root element. - * @param componentClass Component class. - * @returns Promise resolved when done. - */ - static async waitComponentReady( - element: Element | null, - componentClass?: ComponentConstructor, - ): Promise { - return CoreDirectivesRegistry.waitDirectiveReady(element, componentClass); - } - - /** - * Waits all elements matching to be ready. - * - * @param element Element where to search. - * @param selector Selector to search on parent. - * @param componentClass Component class. - * @returns Promise resolved when done. - */ - static async waitComponentsReady( - element: Element, - selector: string, - componentClass?: ComponentConstructor, - ): Promise { - return CoreDirectivesRegistry.waitDirectivesReady(element, selector, componentClass); - } - -} - -/** - * Component constructor. - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export type ComponentConstructor = { new(...args: any[]): T }; diff --git a/src/core/singletons/dom.ts b/src/core/singletons/dom.ts index ff22077c0..07c0c425e 100644 --- a/src/core/singletons/dom.ts +++ b/src/core/singletons/dom.ts @@ -535,20 +535,6 @@ export class CoreDom { ); } - /** - * Listen to click and Enter/Space keys in an element. - * - * @param element Element to listen to events. - * @param callback Callback to call when clicked or the key is pressed. - * @deprecated since 4.1.1: Use initializeClickableElementA11y instead. - */ - static onActivate( - element: HTMLElement & {disabled?: boolean}, - callback: (event: MouseEvent | KeyboardEvent) => void, - ): void { - this.initializeClickableElementA11y(element, callback); - } - /** * Initializes a clickable element a11y calling the click action when pressed enter or space * and adding tabindex and role if needed. diff --git a/src/core/singletons/html-classes.ts b/src/core/singletons/html-classes.ts index ccf0e199a..ff74fda5b 100644 --- a/src/core/singletons/html-classes.ts +++ b/src/core/singletons/html-classes.ts @@ -72,9 +72,9 @@ export class CoreHTMLClasses { parts[1] = parts[1] || '0'; parts[2] = parts[2] || '0'; - CoreDomUtils.toggleModeClass(prefix + parts[0], true, { includeLegacy: true }); - CoreDomUtils.toggleModeClass(prefix + parts[0] + '-' + parts[1], true, { includeLegacy: true }); - CoreDomUtils.toggleModeClass(prefix + parts[0] + '-' + parts[1] + '-' + parts[2], true, { includeLegacy: true }); + CoreDomUtils.toggleModeClass(prefix + parts[0], true); + CoreDomUtils.toggleModeClass(prefix + parts[0] + '-' + parts[1], true); + CoreDomUtils.toggleModeClass(prefix + parts[0] + '-' + parts[1] + '-' + parts[2], true); } /** @@ -88,7 +88,7 @@ export class CoreHTMLClasses { continue; } - CoreDomUtils.toggleModeClass(modeClass, false, { includeLegacy: true }); + CoreDomUtils.toggleModeClass(modeClass, false); } } diff --git a/src/core/singletons/text.ts b/src/core/singletons/text.ts index 93fd9580c..05768f8fc 100644 --- a/src/core/singletons/text.ts +++ b/src/core/singletons/text.ts @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CorePath } from './path'; - /** * Singleton with helper functions for text manipulation. */ @@ -70,16 +68,4 @@ export class CoreText { return text.substring(1); } - /** - * Concatenate two paths, adding a slash between them if needed. - * - * @param leftPath Left path. - * @param rightPath Right path. - * @returns Concatenated path. - * @deprecated since 4.1. Use CorePath.concatenatePaths instead. - */ - static concatenatePaths(leftPath: string, rightPath: string): string { - return CorePath.concatenatePaths(leftPath, rightPath); - } - }