Merge pull request #3309 from NoelDeMartin/MOBILE-3321

MOBILE-3321: Integrate Storybook
main
Dani Palou 2022-06-08 13:45:58 +02:00 committed by GitHub
commit 3a79dd8c54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
122 changed files with 10498 additions and 377 deletions

View File

@ -0,0 +1,4 @@
module.exports = {
framework: '@storybook/angular',
stories: ['../src/**/*.stories.ts'],
}

View File

@ -0,0 +1,11 @@
{
"extends": "../tsconfig.json",
"include": [
"../src/**/*"
],
"exclude": [
"../src/**/tests/**",
"../src/testing/**",
"../src/**/*.test.ts"
]
}

9833
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,7 @@
"dev:ios": "ionic cordova run ios",
"prod:android": "NODE_ENV=production ionic cordova run android --prod",
"prod:ios": "NODE_ENV=production ionic cordova run ios --prod",
"storybook": "start-storybook -p 6006",
"test": "NODE_ENV=testing gulp && jest --verbose",
"test:ci": "NODE_ENV=testing gulp && jest -ci --runInBand --verbose",
"test:watch": "NODE_ENV=testing gulp watch & jest --watch",
@ -35,7 +36,8 @@
"lint": "NODE_OPTIONS=--max-old-space-size=4096 ng lint",
"ionic:serve:before": "gulp",
"ionic:serve": "cross-env-shell ./scripts/serve.sh",
"ionic:build:before": "gulp"
"ionic:build:before": "gulp",
"postinstall": "patch-package"
},
"dependencies": {
"@angular/animations": "~10.0.14",
@ -138,6 +140,7 @@
"@angular/language-service": "~10.0.14",
"@ionic/angular-toolkit": "^2.3.3",
"@ionic/cli": "^6.19.0",
"@storybook/angular": "~6.1",
"@types/faker": "^5.1.3",
"@types/node": "^12.12.64",
"@types/resize-observer-browser": "^0.1.5",
@ -145,6 +148,7 @@
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"check-es-compat": "^1.1.1",
"compare-versions": "^4.1.3",
"cordova-plugin-androidx-adapter": "^1.1.3",
"cordova-plugin-screen-orientation": "^3.0.2",
"cross-env": "^7.0.3",
@ -169,6 +173,7 @@
"jest-preset-angular": "^8.3.1",
"jsonc-parser": "^2.3.1",
"native-run": "^1.4.0",
"patch-package": "^6.4.7",
"terser-webpack-plugin": "^4.2.3",
"ts-jest": "^26.4.1",
"ts-node": "~8.3.0",

View File

@ -0,0 +1,21 @@
diff --git a/node_modules/eslint-plugin-ecmascript-compat/lib/compatibility.js b/node_modules/eslint-plugin-ecmascript-compat/lib/compatibility.js
index 57772cd..f3667fd 100644
--- a/node_modules/eslint-plugin-ecmascript-compat/lib/compatibility.js
+++ b/node_modules/eslint-plugin-ecmascript-compat/lib/compatibility.js
@@ -1,5 +1,7 @@
/* eslint-disable camelcase, no-underscore-dangle */
+const compareVersions = require('compare-versions').compare;
+
function forbiddenFeatures(features, targets) {
return features.filter(feature => !isFeatureSupportedByTargets(feature, targets));
}
@@ -30,7 +32,7 @@ function isCompatFeatureSupportedByTarget(compatFeature, target) {
return true;
}
- return !support.isNone && target.version >= versionAdded;
+ return !support.isNone && target.version.split('-').every(version => compareVersions(version, versionAdded, '>='));
}
function getSimpleSupportStatement(compatFeature, target) {

View File

@ -41,7 +41,7 @@ import {
import { AddonCalendarFilter, AddonCalendarHelper } from '../../services/calendar-helper';
import { AddonCalendarOffline } from '../../services/calendar-offline';
import { CoreCategoryData, CoreCourses } from '@features/courses/services/courses';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSwipeSlidesComponent } from '@components/swipe-slides/swipe-slides';
import {
CoreSwipeSlidesDynamicItem,
@ -498,7 +498,7 @@ class AddonCalendarMonthSlidesItemsManagerSource extends CoreSwipeSlidesDynamicI
// Don't pass courseId and categoryId, we'll filter them locally.
result = await AddonCalendar.getMonthlyEvents(year, monthNumber);
} catch (error) {
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Allow navigating to non-cached months in offline (behave as if using emergency cache).
result = await AddonCalendarHelper.getOfflineMonthWeeks(year, monthNumber);
} else {

View File

@ -14,7 +14,7 @@
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { IonRefresher } from '@ionic/angular';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
@ -183,7 +183,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
this.onlineObserver = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
});
});
}
@ -237,7 +237,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
*/
async fetchData(sync?: boolean): Promise<void> {
this.syncIcon = CoreConstants.ICON_LOADING;
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
if (sync) {
await this.sync();
@ -674,7 +674,7 @@ class AddonCalendarDaySlidesItemsManagerSource extends CoreSwipeSlidesDynamicIte
);
} catch (error) {
// Allow navigating to non-cached days in offline (behave as if using emergency cache).
if (CoreApp.isOnline()) {
if (CoreNetwork.isOnline()) {
throw error;
}
}

View File

@ -23,7 +23,7 @@ import {
import { AddonCalendarEventReminder, AddonCalendarHelper } from '../../services/calendar-helper';
import { AddonCalendarOffline } from '../../services/calendar-offline';
import { AddonCalendarSync, AddonCalendarSyncEvents, AddonCalendarSyncProvider } from '../../services/calendar-sync';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
@ -126,7 +126,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
this.onlineObserver = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
});
});
@ -184,7 +184,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
* @return Promise resolved when done.
*/
async fetchEvent(sync = false, showErrors = false): Promise<void> {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
if (sync) {
const deleted = await this.syncEvents(showErrors);

View File

@ -14,7 +14,7 @@
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { IonRefresher } from '@ionic/angular';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
@ -156,7 +156,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
this.onlineObserver = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
});
});
}
@ -193,7 +193,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
async fetchData(sync?: boolean, showErrors?: boolean): Promise<void> {
this.syncIcon = CoreConstants.ICON_LOADING;
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
if (sync) {
// Try to synchronize offline events.

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreSyncBaseProvider, CoreSyncBlockedError } from '@classes/base-sync';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreEvents } from '@singletons/events';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
@ -134,7 +134,7 @@ export class AddonCalendarSyncProvider extends CoreSyncBaseProvider<AddonCalenda
const eventIds: number[] = await CoreUtils.ignoreErrors(AddonCalendarOffline.getAllEventsIds(siteId), []);
if (eventIds.length > 0) {
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -15,7 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreTextUtils } from '@services/utils/text';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUrlUtils } from '@services/utils/url';
@ -241,7 +241,7 @@ export class AddonCalendarProvider {
const storeOffline = (): Promise<boolean> =>
AddonCalendarOffline.markDeleted(eventId, name, deleteAll, siteId).then(() => false);
if (forceOffline || !CoreApp.isOnline()) {
if (forceOffline || !CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}
@ -1074,7 +1074,7 @@ export class AddonCalendarProvider {
});
// Store starting week day preference, we need it in offline to show months that are not in cache.
if (CoreApp.isOnline()) {
if (CoreNetwork.isOnline()) {
CoreConfig.set(AddonCalendarProvider.STARTING_WEEK_DAY, response.daynames[0].dayno);
}
@ -1707,7 +1707,7 @@ export class AddonCalendarProvider {
return { sent: false, event };
};
if (options.forceOffline || !CoreApp.isOnline()) {
if (options.forceOffline || !CoreNetwork.isOnline()) {
// App is offline, store the event.
return storeOffline();
}

View File

@ -20,7 +20,6 @@ import {
AddonMessages,
} from '../../services/messages';
import { CoreUser } from '@features/user/services/user';
import { CoreApp } from '@services/app';
import { CoreConfig } from '@services/config';
import { CoreEvents } from '@singletons/events';
import { CoreSites } from '@services/sites';
@ -28,6 +27,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreConstants } from '@/core/constants';
import { IonRefresher } from '@ionic/angular';
import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications';
import { CorePlatform } from '@services/platform';
/**
* Page that displays the messages settings page.
@ -66,7 +66,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy {
}
protected async asyncInit(): Promise<void> {
this.sendOnEnter = !!(await CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CoreApp.isMobile()));
this.sendOnEnter = !!(await CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CorePlatform.isMobile()));
}
/**

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreTextUtils } from '@services/utils/text';
import {
AddonMessagesOfflineConversationMessagesDBRecord,
@ -283,7 +283,7 @@ export class AddonMessagesOfflineProvider {
conversationid: conversation.id,
text: message,
timecreated: Date.now(),
deviceoffline: CoreApp.isOnline() ? 0 : 1,
deviceoffline: CoreNetwork.isOnline() ? 0 : 1,
conversation: JSON.stringify({
name: conversation.name || '',
subname: conversation.subname || '',
@ -314,7 +314,7 @@ export class AddonMessagesOfflineProvider {
useridfrom: site.getUserId(),
smallmessage: message,
timecreated: new Date().getTime(),
deviceoffline: CoreApp.isOnline() ? 0 : 1,
deviceoffline: CoreNetwork.isOnline() ? 0 : 1,
};
await site.getDb().insertRecord(MESSAGES_TABLE, entry);

View File

@ -26,7 +26,7 @@ import { CoreEvents } from '@singletons/events';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton, Translate } from '@singletons';
import { CoreSites } from '@services/sites';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreConstants } from '@/core/constants';
import { CoreUser } from '@features/user/services/user';
import { CoreError } from '@classes/errors/error';
@ -193,7 +193,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
if (!messages.length) {
// Nothing to sync.
return result;
} else if (!CoreApp.isOnline()) {
} else if (!CoreNetwork.isOnline()) {
// Cannot sync in offline. Mark messages as device offline.
AddonMessagesOffline.setMessagesDeviceOffline(messages, true);
@ -228,7 +228,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
} catch (error) {
if (!CoreUtils.isWebServiceError(error)) {
// Error sending, stop execution.
if (CoreApp.isOnline()) {
if (CoreNetwork.isOnline()) {
// App is online, unmark deviceoffline if marked.
AddonMessagesOffline.setMessagesDeviceOffline(messages, false);
}

View File

@ -15,7 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreLogger } from '@singletons/logger';
import { CoreSites } from '@services/sites';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreUser, CoreUserBasicData } from '@features/user/services/user';
import {
AddonMessagesOffline,
@ -2424,7 +2424,7 @@ export class AddonMessagesProvider {
siteId = siteId || CoreSites.getCurrentSiteId();
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the message.
return storeOffline();
}
@ -2555,7 +2555,7 @@ export class AddonMessagesProvider {
};
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the message.
return storeOffline();
}

View File

@ -49,7 +49,7 @@ import { AddonModAssignOffline } from '../../services/assign-offline';
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreNavigator } from '@services/navigator';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper';
import { CoreLang } from '@services/lang';
import { CoreError } from '@classes/errors/error';
@ -292,7 +292,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
return;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
return;

View File

@ -35,7 +35,7 @@ import {
import { CoreSync } from '@services/sync';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreUtils } from '@services/utils/utils';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper';
import { AddonModAssignSubmissionDelegate } from './submission-delegate';
@ -215,7 +215,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
return result;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -24,7 +24,7 @@ import { CoreGrades } from '@features/grades/services/grades';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreError } from '@classes/errors/error';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreUtils } from '@services/utils/utils';
import { AddonModAssignOffline } from './assign-offline';
import { AddonModAssignSubmissionDelegate } from './submission-delegate';
@ -1027,7 +1027,7 @@ export class AddonModAssignProvider {
return false;
};
if (allowOffline && !CoreApp.isOnline()) {
if (allowOffline && !CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}
@ -1137,7 +1137,7 @@ export class AddonModAssignProvider {
return false;
};
if (forceOffline || !CoreApp.isOnline()) {
if (forceOffline || !CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}
@ -1234,7 +1234,7 @@ export class AddonModAssignProvider {
return false;
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}

View File

@ -25,7 +25,7 @@ import { CoreCourseModuleData } from '@features/course/services/course-helper';
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
import { CoreTag, CoreTagItem } from '@features/tag/services/tag';
import { IonRefresher } from '@ionic/angular';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreNavigator } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
@ -190,7 +190,7 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy {
if (!module.contents?.length || (refresh && !contentsAlreadyLoaded)) {
// Try to load the contents.
const ignoreCache = refresh && CoreApp.isOnline();
const ignoreCache = refresh && CoreNetwork.isOnline();
try {
await CoreCourse.loadModuleContents(module, undefined, undefined, false, ignoreCache);

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { ModalController, Network, NgZone } from '@singletons';
@ -40,12 +40,12 @@ export class AddonModChatUsersModalComponent implements OnInit, OnDestroy {
protected onlineSubscription: Subscription;
constructor() {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
this.currentUserId = CoreSites.getCurrentSiteUserId();
this.onlineSubscription = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
});
});
}

View File

@ -18,6 +18,7 @@ import { CoreSendMessageFormComponent } from '@components/send-message-form/send
import { CanLeave } from '@guards/can-leave';
import { IonContent } from '@ionic/angular';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
@ -65,11 +66,11 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave {
constructor() {
this.currentUserId = CoreSites.getCurrentSiteUserId();
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
this.onlineSubscription = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
});
});
}

View File

@ -17,7 +17,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
import { CoreCourse } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
@ -160,7 +160,7 @@ export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvid
return result;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -18,7 +18,7 @@ import { CoreWSError } from '@classes/errors/wserror';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
@ -90,7 +90,7 @@ export class AddonModChoiceProvider {
return false;
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}
@ -407,7 +407,7 @@ export class AddonModChoiceProvider {
return false;
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}

View File

@ -21,7 +21,7 @@ import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreRatingSync } from '@features/rating/services/rating-sync';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFileEntry } from '@services/file-helper';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSync } from '@services/sync';
@ -184,7 +184,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
return result;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -19,7 +19,7 @@ import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreRatingInfo } from '@features/rating/services/rating';
import { CoreTagItem } from '@features/tag/services/tag';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFileEntry } from '@services/file-helper';
import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
@ -136,7 +136,7 @@ export class AddonModDataProvider {
};
// Checks to store offline.
if (!CoreApp.isOnline() || forceOffline) {
if (!CoreNetwork.isOnline() || forceOffline) {
const notifications = this.checkFields(fields, contents);
if (notifications.length > 0) {
return { fieldnotifications: notifications };
@ -147,7 +147,7 @@ export class AddonModDataProvider {
await this.deleteEntryOfflineAction(dataId, entryId, AddonModDataAction.ADD, siteId);
// App is offline, store the action.
if (!CoreApp.isOnline() || forceOffline) {
if (!CoreNetwork.isOnline() || forceOffline) {
return storeOffline();
}
@ -234,7 +234,7 @@ export class AddonModDataProvider {
return;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}
@ -333,7 +333,7 @@ export class AddonModDataProvider {
return;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}
@ -436,7 +436,7 @@ export class AddonModDataProvider {
};
};
if (!CoreApp.isOnline() || forceOffline) {
if (!CoreNetwork.isOnline() || forceOffline) {
const notifications = this.checkFields(fields, contents);
if (notifications.length > 0) {
return { fieldnotifications: notifications };
@ -446,7 +446,7 @@ export class AddonModDataProvider {
// Remove unnecessary not synced actions.
await this.deleteEntryOfflineAction(dataId, entryId, AddonModDataAction.EDIT, siteId);
if (!CoreApp.isOnline() || forceOffline) {
if (!CoreNetwork.isOnline() || forceOffline) {
// App is offline, store the action.
return storeOffline();
}

View File

@ -19,7 +19,7 @@ import { CoreCourse, CoreCourseCommonModWSOptions } from '@features/course/servi
import { CoreCourseModuleData } from '@features/course/services/course-helper';
import { CanLeave } from '@guards/can-leave';
import { IonContent } from '@ionic/angular';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreNavigator } from '@services/navigator';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
@ -83,7 +83,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
this.onlineObserver = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.offline = !CoreApp.isOnline();
this.offline = !CoreNetwork.isOnline();
});
});
}
@ -160,7 +160,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
try {
this.module = await CoreCourse.getModule(this.cmId, this.courseId, undefined, true, false, this.currentSite.getId());
this.offline = !CoreApp.isOnline();
this.offline = !CoreNetwork.isOnline();
const options = {
cmId: this.cmId,
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,

View File

@ -18,7 +18,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSync } from '@services/sync';
import { CoreUtils } from '@services/utils/utils';
@ -174,7 +174,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
return result;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -17,7 +17,7 @@ import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
@ -1187,7 +1187,7 @@ export class AddonModFeedbackProvider {
return response;
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}

View File

@ -14,7 +14,7 @@
import { Component, Input, OnInit } from '@angular/core';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { AddonModForum, AddonModForumPost } from '@addons/mod/forum/services/forum';
import { PopoverController } from '@singletons';
import { CoreDomUtils } from '@services/utils/dom';
@ -101,7 +101,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit {
*/
deletePost(): void {
if (!this.offlinePost) {
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
CoreDomUtils.showErrorModal(new CoreNetworkError());
return;
@ -117,7 +117,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit {
* Edit a post.
*/
editPost(): void {
if (!this.offlinePost && !CoreApp.isOnline()) {
if (!this.offlinePost && !CoreNetwork.isOnline()) {
CoreDomUtils.showErrorModal(new CoreNetworkError());
return;

View File

@ -24,7 +24,7 @@ import { CoreRatingSyncProvider } from '@features/rating/services/rating-sync';
import { CoreUser } from '@features/user/services/user';
import { CanLeave } from '@guards/can-leave';
import { IonContent, IonRefresher } from '@ionic/angular';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreNavigator } from '@services/navigator';
import { CoreScreen } from '@services/screen';
import { CoreSites } from '@services/sites';
@ -164,12 +164,12 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
return;
}
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
this.externalUrl = CoreSites.getCurrentSite()?.createSiteUrl('/mod/forum/discuss.php', { d: this.discussionId.toString() });
this.onlineObserver = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
});
});

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreUser } from '@features/user/services/user';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFile } from '@services/file';
import { CoreSites } from '@services/sites';
import { CoreTimeUtils } from '@services/utils/time';
@ -124,7 +124,7 @@ export class AddonModForumHelperProvider {
await AddonModForumOffline.deleteNewDiscussion(forumId, timeCreated, siteId);
}
if (saveOffline || !CoreApp.isOnline()) {
if (saveOffline || !CoreNetwork.isOnline()) {
await storeOffline();
return null;

View File

@ -18,7 +18,7 @@ import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/act
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
import { CoreRatingSync } from '@features/rating/services/rating-sync';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreGroups } from '@services/groups';
import { CoreSites } from '@services/sites';
import { CoreSync } from '@services/sync';
@ -230,7 +230,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
[] as AddonModForumOfflineDiscussion[],
);
if (discussions.length !== 0 && !CoreApp.isOnline()) {
if (discussions.length !== 0 && !CoreNetwork.isOnline()) {
throw new Error('cannot sync in offline');
}
@ -369,7 +369,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
if (!replies.length) {
// Nothing to sync.
return { warnings: [], updated: false };
} else if (!CoreApp.isOnline()) {
} else if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
return Promise.reject(null);
}
@ -458,7 +458,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
[] as AddonModForumOfflineReply[],
);
if (replies.length !== 0 && !CoreApp.isOnline()) {
if (replies.length !== 0 && !CoreNetwork.isOnline()) {
throw new Error('Cannot sync in offline');
}

View File

@ -20,7 +20,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreRatingInfo } from '@features/rating/services/rating';
import { CoreTagItem } from '@features/tag/services/tag';
import { CoreUser } from '@features/user/services/user';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFileEntry } from '@services/file-helper';
import { CoreGroups } from '@services/groups';
import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@services/sites';
@ -756,7 +756,7 @@ export class AddonModForumProvider {
} catch (error) {
// Try to get the data from cache stored with the old WS method.
if (
CoreApp.isOnline() ||
CoreNetwork.isOnline() ||
method !== 'mod_forum_get_forum_discussions' ||
options.sortOrder !== AddonModForumProvider.SORTORDER_LASTPOST_DESC
) {
@ -1065,7 +1065,7 @@ export class AddonModForumProvider {
return false;
};
if (!CoreApp.isOnline() && allowOffline) {
if (!CoreNetwork.isOnline() && allowOffline) {
// App is offline, store the action.
return storeOffline();
}

View File

@ -19,7 +19,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreRatingSync } from '@features/rating/services/rating-sync';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreSync } from '@services/sync';
import { CoreUtils } from '@services/utils/utils';
@ -189,7 +189,7 @@ export class AddonModGlossarySyncProvider extends CoreCourseActivitySyncBaseProv
await CoreUtils.ignoreErrors(this.setSyncTime(syncId, siteId));
return result;
} else if (!CoreApp.isOnline()) {
} else if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -20,7 +20,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreRatingInfo } from '@features/rating/services/rating';
import { CoreTagItem } from '@features/tag/services/tag';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
@ -898,7 +898,7 @@ export class AddonModGlossaryProvider {
return false;
};
if (!CoreApp.isOnline() && otherOptions.allowOffline) {
if (!CoreNetwork.isOnline() && otherOptions.allowOffline) {
// App is offline, store the action.
return storeOffline();
}

View File

@ -24,7 +24,7 @@ import { CoreH5PHelper } from '@features/h5p/classes/helper';
import { CoreH5P } from '@features/h5p/services/h5p';
import { CoreXAPIOffline } from '@features/xapi/services/offline';
import { CoreXAPI } from '@features/xapi/services/xapi';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFilepool } from '@services/filepool';
import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites';
@ -149,7 +149,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
// Cannot download the file or already downloaded, play the package directly.
this.play();
} else if ((this.state == CoreConstants.NOT_DOWNLOADED || this.state == CoreConstants.OUTDATED) && CoreApp.isOnline() &&
} else if ((this.state == CoreConstants.NOT_DOWNLOADED || this.state == CoreConstants.OUTDATED) && CoreNetwork.isOnline() &&
this.deployedFile?.filesize && CoreFilepool.shouldDownload(this.deployedFile.filesize)) {
// Package is small, download it automatically. Don't block this function for this.
this.downloadAutomatically();
@ -280,7 +280,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
return;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
return;

View File

@ -19,7 +19,7 @@ import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/act
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreXAPIOffline } from '@features/xapi/services/offline';
import { CoreXAPI } from '@features/xapi/services/xapi';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
@ -103,7 +103,7 @@ export class AddonModH5PActivitySyncProvider extends CoreCourseActivitySyncBaseP
syncActivity(contextId: number, siteId?: string): Promise<AddonModH5PActivitySyncResult> {
siteId = siteId || CoreSites.getCurrentSiteId();
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -21,7 +21,7 @@ import { CoreCourse } from '@features/course/services/course';
import { CoreCourseModuleData } from '@features/course/services/course-helper';
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
import { IonRefresher } from '@ionic/angular';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreNavigator } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
@ -189,7 +189,7 @@ export class AddonModImscpViewPage implements OnInit {
if (!module.contents?.length || (refresh && !contentsAlreadyLoaded)) {
// Try to load the contents.
const ignoreCache = refresh && CoreApp.isOnline();
const ignoreCache = refresh && CoreNetwork.isOnline();
try {
await CoreCourse.loadModuleContents(module, undefined, undefined, false, ignoreCache);

View File

@ -18,7 +18,7 @@ import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course';
import { CoreCourseModuleData } from '@features/course/services/course-helper';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFilepool } from '@services/filepool';
import { CoreSitesCommonWSOptions, CoreSites } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
@ -181,7 +181,7 @@ export class AddonModImscpProvider {
return CoreText.concatenatePaths(dirPath, itemHref);
} catch (error) {
// Error getting directory, there was an error downloading or we're in browser. Return online URL if connected.
if (CoreApp.isOnline()) {
if (CoreNetwork.isOnline()) {
const contents = await CoreCourse.getModuleContents(module);
const indexUrl = this.getFileUrlFromContents(contents, itemHref);

View File

@ -18,7 +18,7 @@ import { IonContent } from '@ionic/angular';
import { CoreError } from '@classes/errors/error';
import { CanLeave } from '@guards/can-leave';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreNavigator } from '@services/navigator';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSync } from '@services/sync';
@ -280,7 +280,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
// If lesson has offline data already, use offline mode.
this.offline = await AddonModLessonOffline.hasOfflineData(this.lesson.id);
if (!this.offline && !CoreApp.isOnline() && AddonModLesson.isLessonOffline(this.lesson) && !this.review) {
if (!this.offline && !CoreNetwork.isOnline() && AddonModLesson.isLessonOffline(this.lesson) && !this.review) {
// Lesson doesn't have offline data, but it allows offline and the device is offline. Use offline mode.
this.offline = true;
}
@ -375,7 +375,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
protected async finishRetake(outOfTime?: boolean): Promise<void> {
this.messages = [];
if (this.offline && CoreApp.isOnline()) {
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),

View File

@ -19,7 +19,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
import { CoreCourse } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSync } from '@services/sync';
import { CoreTimeUtils } from '@services/utils/time';
@ -275,7 +275,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid
if (!attempts.length) {
return;
} else if (!CoreApp.isOnline()) {
} else if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}
@ -420,7 +420,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid
await AddonModLessonOffline.deleteRetake(lessonId, siteId);
return;
} else if (!CoreApp.isOnline()) {
} else if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -17,8 +17,8 @@ import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreApp } from '@services/app';
import { CoreFile } from '@services/file';
import { CorePlatform } from '@services/platform';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUrlUtils } from '@services/utils/url';
@ -251,7 +251,7 @@ export class AddonModLtiProvider {
// Generate launcher and open it.
const launcherUrl = await this.generateLauncher(url, params);
if (CoreApp.isMobile()) {
if (CorePlatform.isMobile()) {
CoreUtils.openInApp(launcherUrl);
} else {
// In desktop open in browser, we found some cases where inapp caused JS issues.

View File

@ -21,7 +21,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
import { CoreQuestion, CoreQuestionQuestionParsed } from '@features/question/services/question';
import { CoreQuestionDelegate } from '@features/question/services/question-delegate';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSync } from '@services/sync';
import { CoreUtils } from '@services/utils/utils';
@ -311,7 +311,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider
return this.finishSync(siteId, quiz, courseId, warnings);
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreError(Translate.instant('core.cannotconnect'));
}

View File

@ -20,6 +20,7 @@ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents
import { CoreCourse } from '@features/course/services/course';
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFileHelper } from '@services/file-helper';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
@ -79,13 +80,13 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
super.ngOnInit();
this.isIOS = CoreApp.isIOS();
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
// Refresh online status when changes.
this.onlineObserver = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
});
});

View File

@ -17,7 +17,7 @@ import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFile } from '@services/file';
import { CoreFileHelper } from '@services/file-helper';
import { CoreFilepool } from '@services/filepool';
@ -80,7 +80,7 @@ export class AddonModResourceHelperProvider {
return CoreText.concatenatePaths(dirPath, mainFilePath);
} catch (e) {
// Error getting directory, there was an error downloading or we're in browser. Return online URL.
if (CoreApp.isOnline() && mainFile.fileurl) {
if (CoreNetwork.isOnline() && mainFile.fileurl) {
// This URL is going to be injected in an iframe, we need this to make it work.
return CoreSites.getRequiredCurrentSite().checkAndFixPluginfileURL(mainFile.fileurl);
}

View File

@ -16,9 +16,9 @@ import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler';
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreApp } from '@services/app';
import { CoreFile } from '@services/file';
import { CoreFilepool } from '@services/filepool';
import { CorePlatform } from '@services/platform';
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
@ -394,7 +394,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
// Remove the unzipped folder.
promises.push(CoreFile.removeDir(path).catch((error) => {
if (error && (error.code == 1 || !CoreApp.isMobile())) {
if (error && (error.code == 1 || !CorePlatform.isMobile())) {
// Not found, ignore error.
} else {
throw error;

View File

@ -17,7 +17,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
import { CoreCourse } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
@ -168,7 +168,7 @@ export class AddonModSurveySyncProvider extends CoreCourseActivitySyncBaseProvid
}
if (answersNumber > 0 && data) {
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -17,7 +17,7 @@ import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
@ -257,7 +257,7 @@ export class AddonModSurveyProvider {
siteId = siteId || CoreSites.getCurrentSiteId();
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the message.
return storeOffline();
}

View File

@ -21,7 +21,7 @@ import { CoreCourse } from '@features/course/services/course';
import { CoreTag, CoreTagItem } from '@features/tag/services/tag';
import { CoreUser } from '@features/user/services/user';
import { IonContent } from '@ionic/angular';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreGroup, CoreGroups } from '@services/groups';
import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites';
@ -116,13 +116,13 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
) {
super('AddonModLessonIndexComponent', content, courseContentsPage);
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
// Refresh online status when changes.
this.onlineSubscription = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
});
});
}

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreSyncBaseProvider, CoreSyncBlockedError } from '@classes/base-sync';
import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreGroups } from '@services/groups';
import { CoreSites } from '@services/sites';
import { CoreSync } from '@services/sync';
@ -224,7 +224,7 @@ export class AddonModWikiSyncProvider extends CoreSyncBaseProvider<AddonModWikiS
return result;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -18,7 +18,7 @@ import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreTagItem } from '@features/tag/services/tag';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreNavigator } from '@services/navigator';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
@ -706,7 +706,7 @@ export class AddonModWikiProvider {
return -1;
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}

View File

@ -17,7 +17,7 @@ import { CoreSyncBaseProvider, CoreSyncBlockedError } from '@classes/base-sync';
import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFileEntry } from '@services/file-helper';
import { CoreSites } from '@services/sites';
import { CoreSync } from '@services/sync';
@ -195,7 +195,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
return result;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -18,7 +18,7 @@ import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreGradesMenuItem } from '@features/grades/services/grades-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreTextFormat, defaultTextFormat } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
@ -729,7 +729,7 @@ export class AddonModWorkshopProvider {
// If we are editing an offline submission, discard previous first.
await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.ADD, siteId);
if (!CoreApp.isOnline() && allowOffline) {
if (!CoreNetwork.isOnline() && allowOffline) {
// App is offline, store the action.
return storeOffline();
}
@ -825,7 +825,7 @@ export class AddonModWorkshopProvider {
// If we are editing an offline discussion, discard previous first.
await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.UPDATE, siteId);
if (!CoreApp.isOnline() && allowOffline) {
if (!CoreNetwork.isOnline() && allowOffline) {
// App is offline, store the action.
return storeOffline();
}
@ -904,7 +904,7 @@ export class AddonModWorkshopProvider {
// If we are editing an offline discussion, discard previous first.
await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.DELETE, siteId);
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}
@ -1173,7 +1173,7 @@ export class AddonModWorkshopProvider {
// If we are editing an offline discussion, discard previous first.
await AddonModWorkshopOffline.deleteAssessment(workshopId, assessmentId, siteId);
if (!CoreApp.isOnline() && allowOffline) {
if (!CoreNetwork.isOnline() && allowOffline) {
// App is offline, store the action.
return storeOffline();
}
@ -1251,7 +1251,7 @@ export class AddonModWorkshopProvider {
// If we are editing an offline discussion, discard previous first.
await AddonModWorkshopOffline.deleteEvaluateSubmission(workshopId, submissionId, siteId);
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}
@ -1342,7 +1342,7 @@ export class AddonModWorkshopProvider {
// If we are editing an offline discussion, discard previous first.
await AddonModWorkshopOffline.deleteEvaluateAssessment(workshopId, assessmentId, siteId);
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreSyncBaseProvider } from '@classes/base-sync';
import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreCourses } from '@features/courses/services/courses';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { Translate, makeSingleton } from '@singletons';
@ -148,7 +148,7 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider<AddonNotesSyncR
return result;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -17,7 +17,7 @@ import { CoreWSError } from '@classes/errors/wserror';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications';
import { CoreUser } from '@features/user/services/user';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalWarning } from '@services/ws';
@ -58,7 +58,7 @@ export class AddonNotesProvider {
return false;
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the note.
return storeOffline();
}
@ -161,7 +161,7 @@ export class AddonNotesProvider {
return false;
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the note.
return storeOffline();
}

View File

@ -14,8 +14,8 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreCronHandler } from '@services/cron';
import { CorePlatform } from '@services/platform';
import { CoreSites } from '@services/sites';
import { makeSingleton } from '@singletons';
import { CoreEvents } from '@singletons/events';
@ -35,7 +35,7 @@ export class AddonNotificationsCronHandlerService implements CoreCronHandler {
* @return Time between consecutive executions (in ms).
*/
getInterval(): number {
return CoreApp.isMobile() ? 600000 : 60000; // 1 or 10 minutes.
return CorePlatform.isMobile() ? 600000 : 60000; // 1 or 10 minutes.
}
/**

View File

@ -16,7 +16,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
import { IonRefresher } from '@ionic/angular';
import { Md5 } from 'ts-md5/dist/md5';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
@ -154,7 +154,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy {
* Upload a new file.
*/
async uploadFile(): Promise<void> {
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true);
return;

View File

@ -32,6 +32,7 @@ import { CoreConstants } from '@/core/constants';
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreDom } from '@singletons/dom';
import { CoreNetwork } from '@services/network';
const MOODLE_VERSION_PREFIX = 'version-';
const MOODLEAPP_VERSION_PREFIX = 'moodleapp-';
@ -310,7 +311,7 @@ export class AppComponent implements OnInit, AfterViewInit {
Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
const isOnline = CoreApp.isOnline();
const isOnline = CoreNetwork.isOnline();
const hadOfflineMessage = document.body.classList.contains('core-offline');
document.body.classList.toggle('core-offline', !isOnline);
@ -327,7 +328,7 @@ export class AppComponent implements OnInit, AfterViewInit {
});
});
const isOnline = CoreApp.isOnline();
const isOnline = CoreNetwork.isOnline();
document.body.classList.toggle('core-offline', !isOnline);
// Set StatusBar properties.

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreSync } from '@services/sync';
import { CoreTextUtils } from '@services/utils/text';
@ -272,7 +272,7 @@ export class CoreSyncBaseProvider<T = void> {
* @return Resolved with siteIds selected. Rejected if offline.
*/
async syncOnSites(syncFunctionLog: string, syncFunction: (siteId: string) => void, siteId?: string): Promise<void> {
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
const message = `Cannot sync '${syncFunctionLog}' because device is offline.`;
this.logger.debug(message);

View File

@ -16,6 +16,7 @@ import { InAppBrowserObject, InAppBrowserOptions } from '@ionic-native/in-app-br
import { Md5 } from 'ts-md5/dist/md5';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreDB } from '@services/db';
import { CoreEvents } from '@singletons/events';
import { CoreFile } from '@services/file';
@ -537,7 +538,7 @@ export class CoreSite {
const initialToken = this.token || '';
data = data || {};
if (!CoreApp.isOnline() && this.offlineDisabled) {
if (!CoreNetwork.isOnline() && this.offlineDisabled) {
throw new CoreError(Translate.instant('core.errorofflinedisabled'));
}
@ -995,7 +996,7 @@ export class CoreSite {
const now = Date.now();
let expirationTime: number | undefined;
preSets.omitExpires = preSets.omitExpires || preSets.forceOffline || !CoreApp.isOnline();
preSets.omitExpires = preSets.omitExpires || preSets.forceOffline || !CoreNetwork.isOnline();
if (!preSets.omitExpires) {
expirationTime = entry.expirationTime + this.getExpirationDelay(preSets.updateFrequency);
@ -1987,7 +1988,7 @@ export class CoreSite {
updateFrequency = updateFrequency || CoreSite.FREQUENCY_USUALLY;
let expirationDelay = this.UPDATE_FREQUENCIES[updateFrequency] || this.UPDATE_FREQUENCIES[CoreSite.FREQUENCY_USUALLY];
if (CoreApp.isNetworkAccessLimited()) {
if (CoreNetwork.isNetworkAccessLimited()) {
// Not WiFi, increase the expiration delay a 50% to decrease the data usage in this case.
expirationDelay *= 1.5;
}
@ -2011,7 +2012,7 @@ export class CoreSite {
} else if (this.tokenPluginFileWorksPromise) {
// Check ongoing, use the same promise.
return this.tokenPluginFileWorksPromise;
} else if (!CoreApp.isOnline()) {
} else if (!CoreNetwork.isOnline()) {
// Not online, cannot check it. Assume it's working, but don't save the result.
return Promise.resolve(true);
}

View File

@ -19,7 +19,7 @@ import { CoreFileUploader, CoreFileUploaderTypeList } from '@features/fileupload
import { CoreSites } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { Translate } from '@singletons';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper';
import { CoreFileEntry } from '@services/file-helper';
@ -132,7 +132,7 @@ export class CoreAttachmentsComponent implements OnInit {
async add(): Promise<void> {
const allowOffline = !!this.allowOffline && this.allowOffline !== 'false';
if (!allowOffline && !CoreApp.isOnline()) {
if (!allowOffline && !CoreNetwork.isOnline()) {
CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true);
return;

View File

@ -14,6 +14,7 @@
import { Component, Input, Output, OnInit, OnDestroy, EventEmitter } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFilepool } from '@services/filepool';
import { CoreFileHelper } from '@services/file-helper';
import { CorePluginFileDelegate } from '@services/plugin-file-delegate';
@ -197,7 +198,7 @@ export class CoreFileComponent implements OnInit, OnDestroy {
return;
}
if (!CoreApp.isOnline() && (!openAfterDownload || (openAfterDownload &&
if (!CoreNetwork.isOnline() && (!openAfterDownload || (openAfterDownload &&
!CoreFileHelper.isStateDownloaded(this.state)))) {
CoreDomUtils.showErrorModal('core.networkerrormsg', true);

View File

@ -13,7 +13,6 @@
// limitations under the License.
import { Component, Input, Output, EventEmitter, OnInit, ViewChild, ElementRef } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreConfig } from '@services/config';
import { CoreEvents } from '@singletons/events';
import { CoreSites } from '@services/sites';
@ -21,6 +20,7 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreTextUtils } from '@services/utils/text';
import { CoreConstants } from '@/core/constants';
import { CoreForms } from '@singletons/form';
import { CorePlatform } from '@services/platform';
/**
* Component to display a "send message form".
@ -55,7 +55,7 @@ export class CoreSendMessageFormComponent implements OnInit {
this.onSubmit = new EventEmitter();
this.onResize = new EventEmitter();
CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CoreApp.isMobile()).then((sendOnEnter) => {
CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CorePlatform.isMobile()).then((sendOnEnter) => {
this.sendOnEnter = !!sendOnEnter;
return;
@ -117,7 +117,7 @@ export class CoreSendMessageFormComponent implements OnInit {
// Enter clicked, send the message.
e.preventDefault();
e.stopPropagation();
} else if (!this.sendOnEnter && !CoreApp.isMobile() && other == 'control') {
} else if (!this.sendOnEnter && !CorePlatform.isMobile() && other == 'control') {
// Cmd+Enter or Ctrl+Enter, send message.
e.preventDefault();
e.stopPropagation();
@ -138,7 +138,7 @@ export class CoreSendMessageFormComponent implements OnInit {
if (this.sendOnEnter && !other) {
// Enter clicked, send the message.
this.submitForm(e);
} else if (!this.sendOnEnter && !CoreApp.isMobile() && other == 'control') {
} else if (!this.sendOnEnter && !CorePlatform.isMobile() && other == 'control') {
// Cmd+Enter or Ctrl+Enter, send message.
this.submitForm(e);
}

View File

@ -0,0 +1,37 @@
// (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 { Meta, moduleMetadata, Story } from '@storybook/angular';
import { story } from '@/storybook/utils/helpers';
import { StorybookModule } from '@/storybook/storybook.module';
import { CoreUserAvatarComponent } from '@components/user-avatar/user-avatar';
export default <Meta> {
title: 'Core/User Avatar',
component: CoreUserAvatarComponent,
decorators: [
moduleMetadata({
declarations: [CoreUserAvatarComponent],
imports: [StorybookModule],
}),
],
};
const Template: Story = () => ({
component: CoreUserAvatarComponent,
});
export const Primary = story(Template);

View File

@ -14,12 +14,12 @@
import { Component, Input, OnInit, OnChanges, OnDestroy, SimpleChange } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreUserProvider, CoreUserBasicData } from '@features/user/services/user';
import { USER_PROFILE_PICTURE_UPDATED, CoreUserBasicData } from '@features/user/services/user';
import { CoreNavigator } from '@services/navigator';
import { CoreNetwork } from '@services/network';
/**
* Component to display a "user avatar".
@ -54,7 +54,7 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy {
this.currentUserId = CoreSites.getCurrentSiteUserId();
this.pictureObserver = CoreEvents.on(
CoreUserProvider.PROFILE_PICTURE_UPDATED,
USER_PROFILE_PICTURE_UPDATED,
(data) => {
if (data.userId == this.userId) {
this.avatarUrl = data.picture;
@ -119,7 +119,7 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy {
return this.user.lastaccess * 1000 >= time;
} else {
// You have to have Internet access first.
return !!this.user.isonline && CoreApp.isOnline();
return !!this.user.isonline && CoreNetwork.isOnline();
}
}

View File

@ -34,6 +34,7 @@ import { CoreError } from '@classes/errors/error';
import { CoreSite } from '@classes/site';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreConstants } from '../constants';
import { CoreNetwork } from '@services/network';
/**
* Directive to handle external content.
@ -427,7 +428,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges, O
clickableEl.addEventListener(eventName, () => {
// User played media or opened a downloadable link.
// Download the file if in wifi and it hasn't been downloaded already (for big files).
if (state !== CoreConstants.DOWNLOADED && state !== CoreConstants.DOWNLOADING && CoreApp.isWifi()) {
if (state !== CoreConstants.DOWNLOADED && state !== CoreConstants.DOWNLOADING && CoreNetwork.isWifi()) {
// We aren't using the result, so it doesn't matter which of the 2 functions we call.
CoreFilepool.getUrlByUrl(site.getId(), url, this.component, this.componentId, 0, false);
}

View File

@ -40,6 +40,7 @@ import { CoreCommentsOffline } from '@features/comments/services/comments-offlin
import { CoreCommentsDBRecord } from '@features/comments/services/database/comments';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import moment from 'moment';
import { Subscription } from 'rxjs';
@ -108,11 +109,11 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy {
}
}, CoreSites.getCurrentSiteId());
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
this.onlineObserver = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
});
});
}

View File

@ -19,7 +19,7 @@ import { CoreEvents } from '@singletons/events';
import { makeSingleton, Translate } from '@singletons';
import { CoreCommentsOffline } from './comments-offline';
import { CoreSites } from '@services/sites';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreUtils } from '@services/utils/utils';
import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreCommentsDBRecord, CoreCommentsDeletedDBRecord } from './database/comments';
@ -204,7 +204,7 @@ export class CoreCommentsSyncProvider extends CoreSyncBaseProvider<CoreCommentsS
return result;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -15,7 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalWarning } from '@services/ws';
@ -95,7 +95,7 @@ export class CoreCommentsProvider {
return false;
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the comment.
return storeOffline();
}
@ -243,7 +243,7 @@ export class CoreCommentsProvider {
return false;
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the comment.
return storeOffline();
}

View File

@ -15,7 +15,7 @@
import { CoreConstants } from '@/core/constants';
import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFilepool } from '@services/filepool';
import { CoreSites } from '@services/sites';
import { CoreCourse, CoreCourseAnyModuleData } from '../services/course';
@ -84,7 +84,7 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot prefetch in offline.
throw new CoreNetworkError();
}

View File

@ -16,7 +16,7 @@ import { CoreConstants } from '@/core/constants';
import { OnInit, OnDestroy, Input, Output, EventEmitter, Component, Optional, Inject } from '@angular/core';
import { CoreAnyError } from '@classes/errors/error';
import { IonRefresher } from '@ionic/angular';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
@ -354,7 +354,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
if (!this.module.contents?.length || (refresh && !contentsAlreadyLoaded)) {
// Try to load the contents.
const ignoreCache = refresh && CoreApp.isOnline();
const ignoreCache = refresh && CoreNetwork.isOnline();
try {
await CoreCourse.loadModuleContents(this.module, undefined, undefined, false, ignoreCache);

View File

@ -14,7 +14,7 @@
import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFilepool } from '@services/filepool';
import { CoreSites } from '@services/sites';
import { CoreWSFile } from '@services/ws';
@ -57,7 +57,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
* @return Promise resolved when all content is downloaded.
*/
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean, dirPath?: string): Promise<void> {
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot download in offline.
throw new CoreNetworkError();
}

View File

@ -23,7 +23,7 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
import { CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses';
import { CoreGradesFormattedRow, CoreGradesFormattedTableRow, CoreGradesHelper } from '@features/grades/services/grades-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFilepool } from '@services/filepool';
import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites';
@ -79,13 +79,13 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
constructor() {
this.siteId = CoreSites.getCurrentSiteId();
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
// Refresh online status when changes.
this.onlineSubscription = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.isOnline = CoreApp.isOnline();
this.isOnline = CoreNetwork.isOnline();
});
});
}

View File

@ -14,7 +14,7 @@
import { Component, Input, OnInit } from '@angular/core';
import { CoreCourseModuleData } from '@features/course/services/course-helper';
import type { CoreCourseModuleData } from '@features/course/services/course-helper';
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
/**

View File

@ -58,7 +58,7 @@ import {
} from './module-prefetch-delegate';
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
import { CoreFileHelper } from '@services/file-helper';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSite } from '@classes/site';
import { CoreFile } from '@services/file';
import { CoreUrlUtils } from '@services/utils/url';
@ -798,7 +798,7 @@ export class CoreCourseHelperProvider {
files?: CoreCourseModuleContentFile[],
options: CoreUtilsOpenFileOptions = {},
): Promise<void> {
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Not online, get the offline file. It will fail if not found.
let path: string | undefined;
try {
@ -950,7 +950,7 @@ export class CoreCourseHelperProvider {
): Promise<string> {
siteId = siteId || CoreSites.getCurrentSiteId();
const isOnline = CoreApp.isOnline();
const isOnline = CoreNetwork.isOnline();
const mainFile = files[0];
const timemodified = mainFile.timemodified || 0;
@ -969,7 +969,7 @@ export class CoreCourseHelperProvider {
}
// Start the download if in wifi, but return the URL right away so the file is opened.
if (CoreApp.isWifi()) {
if (CoreNetwork.isWifi()) {
this.downloadModule(module, courseId, component, componentId, files, siteId);
}

View File

@ -15,7 +15,7 @@
import { Injectable } from '@angular/core';
import { Params } from '@angular/router';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreEvents } from '@singletons/events';
import { CoreLogger } from '@singletons/logger';
import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@services/sites';
@ -554,7 +554,7 @@ export class CoreCourseProvider {
return sections;
} catch {
// The module might still be cached by a request with different parameters.
if (!ignoreCache && !CoreApp.isOnline()) {
if (!ignoreCache && !CoreNetwork.isOnline()) {
if (includeStealth) {
// Older versions didn't include the includestealthmodules option.
return doRequest(site, courseId, moduleId, modName, false, true);
@ -1168,7 +1168,7 @@ export class CoreCourseProvider {
CoreCourseOffline.markCompletedManually(cmId, completed, courseId, undefined, siteId);
// The offline function requires a courseId and it could be missing because it's a calculated field.
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { CoreTimeUtils } from '@services/utils/time';
@ -134,7 +134,7 @@ export class CoreCourseLogHelperProvider {
async log(ws: string, data: Record<string, unknown>, component: string, componentId: number, siteId?: string): Promise<void> {
const site = await CoreSites.getSite(siteId);
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return this.storeOffline(ws, data, component, componentId, site.getId());
}

View File

@ -17,7 +17,7 @@ import { Injectable } from '@angular/core';
import { CoreSyncBaseProvider } from '@classes/base-sync';
import { CoreSites } from '@services/sites';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreUtils } from '@services/utils/utils';
import { CoreTextUtils } from '@services/utils/text';
import { CoreCourseOffline } from './course-offline';
@ -167,7 +167,7 @@ export class CoreCourseSyncProvider extends CoreSyncBaseProvider<CoreCourseSyncR
return result;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -28,7 +28,6 @@ import { FormControl } from '@angular/forms';
import { IonTextarea, IonContent, IonSlides } from '@ionic/angular';
import { Subscription } from 'rxjs';
import { CoreApp } from '@services/app';
import { CoreSites } from '@services/sites';
import { CoreFilepool } from '@services/filepool';
import { CoreDomUtils } from '@services/utils/dom';
@ -42,6 +41,7 @@ import { CoreLoadingComponent } from '@components/loading/loading';
import { CoreScreen } from '@services/screen';
import { CoreCancellablePromise } from '@classes/cancellable-promise';
import { CoreDom } from '@singletons/dom';
import { CorePlatform } from '@services/platform';
/**
* Component to display a rich text editor if enabled.
@ -797,7 +797,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
const selection = window.getSelection()?.toString();
// When RTE is focused with a whole paragraph in desktop the stopBubble will not fire click.
if (CoreApp.isMobile() || !this.rteEnabled || document.activeElement != this.editorElement || selection == '') {
if (CorePlatform.isMobile() || !this.rteEnabled || document.activeElement != this.editorElement || selection == '') {
this.stopBubble(event);
}
}

View File

@ -17,7 +17,6 @@ import { MediaObject } from '@ionic-native/media/ngx';
import { FileEntry } from '@ionic-native/file/ngx';
import { MediaFile } from '@ionic-native/media-capture/ngx';
import { CoreApp } from '@services/app';
import { CoreFile, CoreFileProvider } from '@services/file';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreMimetypeUtils } from '@services/utils/mimetype';
@ -27,6 +26,7 @@ import { CoreError } from '@classes/errors/error';
import { CoreCaptureError } from '@classes/errors/captureerror';
import { CoreCanceledError } from '@classes/errors/cancelederror';
import { CoreText } from '@singletons/text';
import { CorePlatform } from '@services/platform';
/**
* Page to capture media in browser, or to capture audio in mobile devices.
@ -116,7 +116,7 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy {
this.title = 'core.captureimage';
}
this.isCordovaAudioCapture = CoreApp.isMobile() && this.isAudio;
this.isCordovaAudioCapture = CorePlatform.isMobile() && this.isAudio;
if (this.isCordovaAudioCapture) {
this.extension = Platform.is('ios') ? 'wav' : 'aac';

View File

@ -20,6 +20,7 @@ import { FileEntry, IFile } from '@ionic-native/file/ngx';
import { MediaFile } from '@ionic-native/media-capture/ngx';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFile, CoreFileProvider, CoreFileProgressEvent } from '@services/file';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreMimetypeUtils } from '@services/utils/mimetype';
@ -37,6 +38,7 @@ import { CoreWSUploadFileResult } from '@services/ws';
import { CoreSites } from '@services/sites';
import { CoreText } from '@singletons/text';
import { CorePromisedValue } from '@classes/promised-value';
import { CorePlatform } from '@services/platform';
/**
* Helper service to upload files.
@ -121,7 +123,7 @@ export class CoreFileUploaderHelperProvider {
return;
}
if (!allowOffline && !CoreApp.isOnline()) {
if (!allowOffline && !CoreNetwork.isOnline()) {
throw new CoreError(Translate.instant('core.fileuploader.errormustbeonlinetoupload'));
}
@ -131,7 +133,7 @@ export class CoreFileUploaderHelperProvider {
if (size < 0) {
return CoreDomUtils.showConfirm(Translate.instant('core.fileuploader.confirmuploadunknownsize'));
} else if (size >= wifiThreshold || (CoreApp.isNetworkAccessLimited() && size >= limitedThreshold)) {
} else if (size >= wifiThreshold || (CoreNetwork.isNetworkAccessLimited() && size >= limitedThreshold)) {
const readableSize = CoreTextUtils.bytesToSize(size, 2);
return CoreDomUtils.showConfirm(
@ -364,7 +366,7 @@ export class CoreFileUploaderHelperProvider {
return false;
}
if (!allowOffline && !CoreApp.isOnline()) {
if (!allowOffline && !CoreNetwork.isOnline()) {
// Not allowed, show error.
CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true);
@ -551,7 +553,7 @@ export class CoreFileUploaderHelperProvider {
media = medias[0]; // We used limit 1, we only want 1 media.
} catch (error) {
if (isAudio && this.isNoAppError(error) && CoreApp.isMobile()) {
if (isAudio && this.isNoAppError(error) && CorePlatform.isMobile()) {
// No app to record audio, fallback to capture it ourselves.
try {
media = await CoreFileUploader.captureAudioInApp();
@ -574,7 +576,7 @@ export class CoreFileUploaderHelperProvider {
}
// Make sure the path has the protocol. In iOS it doesn't.
if (CoreApp.isMobile() && path.indexOf('file://') == -1) {
if (CorePlatform.isMobile() && path.indexOf('file://') == -1) {
path = 'file://' + path;
}
@ -795,7 +797,7 @@ export class CoreFileUploaderHelperProvider {
return this.uploadFile(path, maxSize, checkSize, options, siteId);
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
return errorUploading(Translate.instant('core.fileuploader.errormustbeonlinetoupload'));
}

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CorePlatform } from '@services/platform';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
@ -35,7 +35,7 @@ export class CoreFileUploaderAlbumHandlerService implements CoreFileUploaderHand
* @return Promise resolved with true if enabled.
*/
async isEnabled(): Promise<boolean> {
return CoreApp.isMobile();
return CorePlatform.isMobile();
}
/**

View File

@ -15,6 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CorePlatform } from '@services/platform';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
@ -34,7 +35,7 @@ export class CoreFileUploaderAudioHandlerService implements CoreFileUploaderHand
* @return Promise resolved with true if enabled.
*/
async isEnabled(): Promise<boolean> {
return CoreApp.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
return CorePlatform.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
}
/**

View File

@ -15,6 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CorePlatform } from '@services/platform';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
@ -35,7 +36,7 @@ export class CoreFileUploaderCameraHandlerService implements CoreFileUploaderHan
* @return Promise resolved with true if enabled.
*/
async isEnabled(): Promise<boolean> {
return CoreApp.isMobile() || CoreApp.canGetUserMedia();
return CorePlatform.isMobile() || CoreApp.canGetUserMedia();
}
/**

View File

@ -20,6 +20,7 @@ import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderH
import { CoreFileUploaderHelper } from '../fileuploader-helper';
import { CoreFileUploader } from '../fileuploader';
import { makeSingleton, Translate } from '@singletons';
import { CorePlatform } from '@services/platform';
/**
* Handler to upload any type of file.
@ -61,7 +62,7 @@ export class CoreFileUploaderFileHandlerService implements CoreFileUploaderHandl
icon: 'folder', // Cannot use font-awesome in action sheet.
};
if (CoreApp.isMobile()) {
if (CorePlatform.isMobile()) {
handler.action = async (
maxSize?: number,
upload?: boolean,

View File

@ -15,6 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CorePlatform } from '@services/platform';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
@ -34,7 +35,7 @@ export class CoreFileUploaderVideoHandlerService implements CoreFileUploaderHand
* @return Promise resolved with true if enabled.
*/
async isEnabled(): Promise<boolean> {
return CoreApp.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
return CorePlatform.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
}
/**

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreFilterDelegate } from './filter-delegate';
import {
@ -299,7 +299,7 @@ export class CoreFilterHelperProvider {
const cachedData = this.moduleContextsCache[siteId][courseId][contextLevel];
if (!CoreApp.isOnline() || Date.now() <= cachedData.time + site.getExpirationDelay(CoreSite.FREQUENCY_RARELY)) {
if (!CoreNetwork.isOnline() || Date.now() <= cachedData.time + site.getExpirationDelay(CoreSite.FREQUENCY_RARELY)) {
// We can use cache, return the filters if found.
return cachedData.contexts[contextLevel] && cachedData.contexts[contextLevel][instanceId];
}

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreSite } from '@classes/site';
import { CoreWSExternalWarning } from '@services/ws';
@ -338,7 +338,7 @@ export class CoreFilterProvider {
// Check if we have the contexts in the memory cache.
const siteContexts = this.contextsCache[site.getId()];
const isOnline = CoreApp.isOnline();
const isOnline = CoreNetwork.isOnline();
const result: CoreFilterClassifiedFilters = {};
let allFound = true;

View File

@ -14,7 +14,7 @@
import { Component, Input, ElementRef, OnInit, OnDestroy, OnChanges, SimpleChange } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreFilepool } from '@services/filepool';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
@ -111,7 +111,7 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy {
* @return Promise resolved when done.
*/
async download(): Promise<void> {
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
return;
@ -144,7 +144,7 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy {
*/
protected async attemptDownloadInBg(): Promise<void> {
if (!this.urlParams || !this.src || !this.siteCanDownload || !CoreH5P.canGetTrustedH5PFileInSite() ||
!CoreApp.isOnline()) {
!CoreNetwork.isOnline()) {
return;
}

View File

@ -18,6 +18,7 @@ import { Subscription } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreLoginHelper } from '@features/login/services/login-helper';
@ -244,7 +245,7 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy {
return;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
return;

View File

@ -16,6 +16,7 @@ import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/co
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
@ -201,7 +202,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
return;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
return;

View File

@ -16,6 +16,7 @@ import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { FormBuilder, FormGroup, ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreConfig } from '@services/config';
import { CoreSites, CoreSiteCheckResponse, CoreLoginSiteInfo, CoreSitesDemoSiteData } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
@ -242,7 +243,7 @@ export class CoreLoginSitePage implements OnInit {
return;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
return;

View File

@ -46,6 +46,7 @@ import { CoreDatabaseTable } from '@classes/database/database-table';
import { CoreDatabaseCachingStrategy, CoreDatabaseTableProxy } from '@classes/database/database-table-proxy';
import { CoreObject } from '@singletons/object';
import { lazyMap, LazyMap } from '@/core/utils/lazy-map';
import { CorePlatform } from '@services/platform';
/**
* Service to handle push notifications.
@ -204,7 +205,7 @@ export class CorePushNotificationsProvider {
* @return Whether the device can be registered in Moodle.
*/
canRegisterOnMoodle(): boolean {
return !!this.pushID && CoreApp.isMobile();
return !!this.pushID && CorePlatform.isMobile();
}
/**
@ -542,7 +543,7 @@ export class CorePushNotificationsProvider {
* @return Promise resolved when device is unregistered.
*/
async unregisterDeviceOnMoodle(site: CoreSite): Promise<void> {
if (!site || !CoreApp.isMobile()) {
if (!site || !CorePlatform.isMobile()) {
throw new CoreError('Cannot unregister device');
}
@ -624,7 +625,7 @@ export class CorePushNotificationsProvider {
const total = counters.reduce((previous, counter) => previous + counter, 0);
if (!CoreApp.isMobile()) {
if (!CorePlatform.isMobile()) {
// Browser doesn't have an app badge, stop.
return total;
}

View File

@ -16,7 +16,7 @@ import { ContextLevel } from '@/core/constants';
import { Injectable } from '@angular/core';
import { CoreSyncBaseProvider } from '@classes/base-sync';
import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
@ -202,7 +202,7 @@ export class CoreRatingSyncProvider extends CoreSyncBaseProvider<CoreRatingSyncI
// Nothing to sync.
return result;
}
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// Cannot sync in offline.
throw new CoreNetworkError();
}

View File

@ -16,7 +16,7 @@ import { ContextLevel } from '@/core/constants';
import { Injectable } from '@angular/core';
import { CoreSiteWSPreSets, CoreSite } from '@classes/site';
import { CoreUser } from '@features/user/services/user';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalWarning } from '@services/ws';
@ -114,7 +114,7 @@ export class CoreRatingProvider {
}, siteId);
};
if (!CoreApp.isOnline()) {
if (!CoreNetwork.isOnline()) {
// App is offline, store the action.
return storeOffline();
}

View File

@ -26,6 +26,8 @@ import { CorePushNotifications } from '@features/pushnotifications/services/push
import { CoreConfig } from '@services/config';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreNavigator } from '@services/navigator';
import { CorePlatform } from '@services/platform';
import { CoreNetwork } from '@services/network';
/**
* Device Info to be shown and copied to clipboard.
@ -91,8 +93,8 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
versionCode: CoreConstants.CONFIG.versioncode,
compilationTime: CoreConstants.BUILD.compilationTime || 0,
lastCommit: CoreConstants.BUILD.lastCommitHash || '',
networkStatus: appProvider.isOnline() ? 'online' : 'offline',
wifiConnection: appProvider.isWifi() ? 'yes' : 'no',
networkStatus: CoreNetwork.isOnline() ? 'online' : 'offline',
wifiConnection: CoreNetwork.isWifi() ? 'yes' : 'no',
localNotifAvailable: CoreLocalNotifications.isAvailable() ? 'yes' : 'no',
pushId: CorePushNotifications.getPushId(),
deviceType: '',
@ -108,7 +110,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
' (' + window.screen.width + 'x' + window.screen.height + ')';
}
if (appProvider.isMobile()) {
if (CorePlatform.isMobile()) {
this.deviceInfo.deviceType = Platform.is('tablet') ? 'tablet' : 'phone';
if (appProvider.isAndroid()) {
this.deviceInfo.deviceOs = 'android';
@ -178,7 +180,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
this.onlineObserver = Network.onChange().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
NgZone.run(() => {
this.deviceInfo.networkStatus = appProvider.isOnline() ? 'online' : 'offline';
this.deviceInfo.networkStatus = CoreNetwork.isOnline() ? 'online' : 'offline';
});
});

View File

@ -14,6 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network';
import { CoreCronDelegate } from '@services/cron';
import { CoreEvents } from '@singletons/events';
import { CoreFilepool } from '@services/filepool';
@ -262,10 +263,10 @@ export class CoreSettingsHelperProvider {
if (site.isLoggedOut()) {
// Cannot sync logged out sites.
throw new CoreError(Translate.instant('core.settings.cannotsyncloggedout'));
} else if (hasSyncHandlers && !CoreApp.isOnline()) {
} else if (hasSyncHandlers && !CoreNetwork.isOnline()) {
// We need connection to execute sync.
throw new CoreError(Translate.instant('core.settings.cannotsyncoffline'));
} else if (hasSyncHandlers && syncOnlyOnWifi && CoreApp.isNetworkAccessLimited()) {
} else if (hasSyncHandlers && syncOnlyOnWifi && CoreNetwork.isNetworkAccessLimited()) {
throw new CoreError(Translate.instant('core.settings.cannotsyncwithoutwifi'));
}

View File

@ -30,6 +30,7 @@ import { CoreEvents } from '@singletons/events';
import { CoreLogger } from '@singletons/logger';
import { CoreSitePluginsModuleHandler } from '../classes/handlers/module-handler';
import { CorePromisedValue } from '@classes/promised-value';
import { CorePlatform } from '@services/platform';
const ROOT_CACHE_KEY = 'CoreSitePlugins:';
@ -90,7 +91,7 @@ export class CoreSitePluginsProvider {
applang: lang,
appcustomurlscheme: CoreConstants.CONFIG.customurlscheme,
appisdesktop: false,
appismobile: CoreApp.isMobile(),
appismobile: CorePlatform.isMobile(),
appiswide: CoreApp.isWide(),
appplatform: 'browser',
};

View File

@ -21,7 +21,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreUser, CoreUserProfile, CoreUserProvider } from '@features/user/services/user';
import { CoreUser, CoreUserProfile, USER_PROFILE_PICTURE_UPDATED, USER_PROFILE_REFRESHED } from '@features/user/services/user';
import { CoreUserHelper } from '@features/user/services/user-helper';
import { CoreNavigator } from '@services/navigator';
import { CoreIonLoadingElement } from '@classes/ion-loading';
@ -65,7 +65,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy {
return;
}
this.obsProfileRefreshed = CoreEvents.on(CoreUserProvider.PROFILE_REFRESHED, (data) => {
this.obsProfileRefreshed = CoreEvents.on(USER_PROFILE_REFRESHED, (data) => {
if (!this.user || !data.user) {
return;
}
@ -147,7 +147,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy {
await CoreSites.updateSiteInfo(this.site.getId());
} catch {
// Cannot update site info. Assume the profile image is the right one.
CoreEvents.trigger(CoreUserProvider.PROFILE_PICTURE_UPDATED, {
CoreEvents.trigger(USER_PROFILE_PICTURE_UPDATED, {
userId: this.userId,
picture: this.user.profileimageurl,
}, this.site.getId());
@ -158,7 +158,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy {
await this.refreshUser();
} else {
// Now they're the same, send event to use the right avatar in the rest of the app.
CoreEvents.trigger(CoreUserProvider.PROFILE_PICTURE_UPDATED, {
CoreEvents.trigger(USER_PROFILE_PICTURE_UPDATED, {
userId: this.userId,
picture: this.user.profileimageurl,
}, this.site.getId());
@ -181,7 +181,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy {
const profileImageURL = await CoreUser.changeProfilePicture(result.itemid, this.userId, this.site.getId());
CoreEvents.trigger(CoreUserProvider.PROFILE_PICTURE_UPDATED, {
CoreEvents.trigger(USER_PROFILE_PICTURE_UPDATED, {
userId: this.userId,
picture: profileImageURL,
}, this.site.getId());
@ -210,7 +210,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy {
event?.complete();
if (this.user) {
CoreEvents.trigger(CoreUserProvider.PROFILE_REFRESHED, {
CoreEvents.trigger(USER_PROFILE_REFRESHED, {
courseId: this.courseId,
userId: this.userId,
user: this.user,

View File

@ -21,7 +21,7 @@ import { CoreSite } from '@classes/site';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreUser, CoreUserProfile, CoreUserProvider } from '@features/user/services/user';
import { CoreUser, CoreUserProfile, USER_PROFILE_REFRESHED } from '@features/user/services/user';
import { CoreUserHelper } from '@features/user/services/user-helper';
import {
CoreUserDelegate,
@ -64,7 +64,7 @@ export class CoreUserProfilePage implements OnInit, OnDestroy {
users?: CoreUserSwipeItemsManager;
constructor(private route: ActivatedRoute) {
this.obsProfileRefreshed = CoreEvents.on(CoreUserProvider.PROFILE_REFRESHED, (data) => {
this.obsProfileRefreshed = CoreEvents.on(USER_PROFILE_REFRESHED, (data) => {
if (!this.user || !data.user) {
return;
}
@ -187,7 +187,7 @@ export class CoreUserProfilePage implements OnInit, OnDestroy {
event?.complete();
if (this.user) {
CoreEvents.trigger(CoreUserProvider.PROFILE_REFRESHED, {
CoreEvents.trigger(USER_PROFILE_REFRESHED, {
courseId: this.courseId,
userId: this.userId,
user: this.user,

Some files were not shown because too many files have changed in this diff Show More