MOBILE-4594 chore: Remove deprecated code on 4.1 and 4.0
parent
b84fdaff7a
commit
2e1626dcfb
|
@ -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<AddonCalendarEventReminder[]> {
|
||||
if (!reminders.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return AddonCalendarHelper.getEventReminders(reminders[0].eventid, timestart, siteId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format reminders, adding calculated data.
|
||||
*
|
||||
|
|
|
@ -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<number> {
|
||||
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<void> {
|
||||
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<CoreReminderDBRecord[]> {
|
||||
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<void> {
|
||||
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<void> {
|
||||
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<void> {
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -55,14 +55,6 @@ export class CorePromisedValue<T = unknown> extends CorePromise<T> {
|
|||
this.rejectPromise = rejectPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns Promise.
|
||||
* @deprecated since 4.1. The instance can be directly used as a promise.
|
||||
*/
|
||||
get promise(): Promise<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
get value(): T | null {
|
||||
return this.resolvedValue ?? null;
|
||||
}
|
||||
|
|
|
@ -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<void> {
|
||||
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<InAppBrowserObject> {
|
||||
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<InAppBrowserObject | void> {
|
||||
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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -31,7 +31,8 @@ import { Component, HostBinding, Input } from '@angular/core';
|
|||
*
|
||||
* <core-course-module-description [description]="myDescription"></core-course-module-description>
|
||||
*
|
||||
* @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',
|
||||
|
|
|
@ -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,
|
||||
],
|
||||
})
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
<core-courses-course-list-item [course]="course" class="core-course-progress" [showDownload]="showDownload"
|
||||
[layout]="showAll ? 'card' : 'summarycard'" />
|
|
@ -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:
|
||||
*
|
||||
* <core-courses-course-progress [course]="course">
|
||||
* </core-courses-course-progress>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<T>(): CorePromisedValue<T> {
|
||||
return new CorePromisedValue<T>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a promise, returns true if it's rejected or false if it's resolved.
|
||||
*
|
||||
|
|
|
@ -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<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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten the first dimension of a multi-dimensional array.
|
||||
*
|
||||
|
|
|
@ -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<T>(element?: Element | null, componentClass?: ComponentConstructor<T>): 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<T>(element: Element, componentClass?: ComponentConstructor<T>): 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<T extends AsyncDirective>(
|
||||
element: Element | null,
|
||||
componentClass?: ComponentConstructor<T>,
|
||||
): Promise<void> {
|
||||
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<T extends AsyncDirective>(
|
||||
element: Element,
|
||||
selector: string,
|
||||
componentClass?: ComponentConstructor<T>,
|
||||
): Promise<void> {
|
||||
return CoreDirectivesRegistry.waitDirectivesReady(element, selector, componentClass);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Component constructor.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type ComponentConstructor<T = Component> = { new(...args: any[]): T };
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue