forked from EVOgeek/Vmeda.Online
		
	Merge pull request #3309 from NoelDeMartin/MOBILE-3321
MOBILE-3321: Integrate Storybook
This commit is contained in:
		
						commit
						3a79dd8c54
					
				
							
								
								
									
										4
									
								
								.storybook/main.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								.storybook/main.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | |||||||
|  | module.exports = { | ||||||
|  |     framework: '@storybook/angular', | ||||||
|  |     stories: ['../src/**/*.stories.ts'], | ||||||
|  | } | ||||||
							
								
								
									
										11
									
								
								.storybook/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								.storybook/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | { | ||||||
|  |   "extends": "../tsconfig.json", | ||||||
|  |   "include": [ | ||||||
|  |     "../src/**/*" | ||||||
|  |   ], | ||||||
|  |   "exclude": [ | ||||||
|  |     "../src/**/tests/**", | ||||||
|  |     "../src/testing/**", | ||||||
|  |     "../src/**/*.test.ts" | ||||||
|  |   ] | ||||||
|  | } | ||||||
							
								
								
									
										9833
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										9833
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -28,6 +28,7 @@ | |||||||
|     "dev:ios": "ionic cordova run ios", |     "dev:ios": "ionic cordova run ios", | ||||||
|     "prod:android": "NODE_ENV=production ionic cordova run android --prod", |     "prod:android": "NODE_ENV=production ionic cordova run android --prod", | ||||||
|     "prod:ios": "NODE_ENV=production ionic cordova run ios --prod", |     "prod:ios": "NODE_ENV=production ionic cordova run ios --prod", | ||||||
|  |     "storybook": "start-storybook -p 6006", | ||||||
|     "test": "NODE_ENV=testing gulp && jest --verbose", |     "test": "NODE_ENV=testing gulp && jest --verbose", | ||||||
|     "test:ci": "NODE_ENV=testing gulp && jest -ci --runInBand --verbose", |     "test:ci": "NODE_ENV=testing gulp && jest -ci --runInBand --verbose", | ||||||
|     "test:watch": "NODE_ENV=testing gulp watch & jest --watch", |     "test:watch": "NODE_ENV=testing gulp watch & jest --watch", | ||||||
| @ -35,7 +36,8 @@ | |||||||
|     "lint": "NODE_OPTIONS=--max-old-space-size=4096 ng lint", |     "lint": "NODE_OPTIONS=--max-old-space-size=4096 ng lint", | ||||||
|     "ionic:serve:before": "gulp", |     "ionic:serve:before": "gulp", | ||||||
|     "ionic:serve": "cross-env-shell ./scripts/serve.sh", |     "ionic:serve": "cross-env-shell ./scripts/serve.sh", | ||||||
|     "ionic:build:before": "gulp" |     "ionic:build:before": "gulp", | ||||||
|  |     "postinstall": "patch-package" | ||||||
|   }, |   }, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@angular/animations": "~10.0.14", |     "@angular/animations": "~10.0.14", | ||||||
| @ -138,6 +140,7 @@ | |||||||
|     "@angular/language-service": "~10.0.14", |     "@angular/language-service": "~10.0.14", | ||||||
|     "@ionic/angular-toolkit": "^2.3.3", |     "@ionic/angular-toolkit": "^2.3.3", | ||||||
|     "@ionic/cli": "^6.19.0", |     "@ionic/cli": "^6.19.0", | ||||||
|  |     "@storybook/angular": "~6.1", | ||||||
|     "@types/faker": "^5.1.3", |     "@types/faker": "^5.1.3", | ||||||
|     "@types/node": "^12.12.64", |     "@types/node": "^12.12.64", | ||||||
|     "@types/resize-observer-browser": "^0.1.5", |     "@types/resize-observer-browser": "^0.1.5", | ||||||
| @ -145,6 +148,7 @@ | |||||||
|     "@typescript-eslint/eslint-plugin": "^4.22.0", |     "@typescript-eslint/eslint-plugin": "^4.22.0", | ||||||
|     "@typescript-eslint/parser": "^4.22.0", |     "@typescript-eslint/parser": "^4.22.0", | ||||||
|     "check-es-compat": "^1.1.1", |     "check-es-compat": "^1.1.1", | ||||||
|  |     "compare-versions": "^4.1.3", | ||||||
|     "cordova-plugin-androidx-adapter": "^1.1.3", |     "cordova-plugin-androidx-adapter": "^1.1.3", | ||||||
|     "cordova-plugin-screen-orientation": "^3.0.2", |     "cordova-plugin-screen-orientation": "^3.0.2", | ||||||
|     "cross-env": "^7.0.3", |     "cross-env": "^7.0.3", | ||||||
| @ -169,6 +173,7 @@ | |||||||
|     "jest-preset-angular": "^8.3.1", |     "jest-preset-angular": "^8.3.1", | ||||||
|     "jsonc-parser": "^2.3.1", |     "jsonc-parser": "^2.3.1", | ||||||
|     "native-run": "^1.4.0", |     "native-run": "^1.4.0", | ||||||
|  |     "patch-package": "^6.4.7", | ||||||
|     "terser-webpack-plugin": "^4.2.3", |     "terser-webpack-plugin": "^4.2.3", | ||||||
|     "ts-jest": "^26.4.1", |     "ts-jest": "^26.4.1", | ||||||
|     "ts-node": "~8.3.0", |     "ts-node": "~8.3.0", | ||||||
|  | |||||||
							
								
								
									
										21
									
								
								patches/eslint-plugin-ecmascript-compat+1.1.1.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								patches/eslint-plugin-ecmascript-compat+1.1.1.patch
									
									
									
									
									
										Normal 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) { | ||||||
| @ -41,7 +41,7 @@ import { | |||||||
| import { AddonCalendarFilter, AddonCalendarHelper } from '../../services/calendar-helper'; | import { AddonCalendarFilter, AddonCalendarHelper } from '../../services/calendar-helper'; | ||||||
| import { AddonCalendarOffline } from '../../services/calendar-offline'; | import { AddonCalendarOffline } from '../../services/calendar-offline'; | ||||||
| import { CoreCategoryData, CoreCourses } from '@features/courses/services/courses'; | 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 { CoreSwipeSlidesComponent } from '@components/swipe-slides/swipe-slides'; | ||||||
| import { | import { | ||||||
|     CoreSwipeSlidesDynamicItem, |     CoreSwipeSlidesDynamicItem, | ||||||
| @ -498,7 +498,7 @@ class AddonCalendarMonthSlidesItemsManagerSource extends CoreSwipeSlidesDynamicI | |||||||
|                 // Don't pass courseId and categoryId, we'll filter them locally.
 |                 // Don't pass courseId and categoryId, we'll filter them locally.
 | ||||||
|                 result = await AddonCalendar.getMonthlyEvents(year, monthNumber); |                 result = await AddonCalendar.getMonthlyEvents(year, monthNumber); | ||||||
|             } catch (error) { |             } catch (error) { | ||||||
|                 if (!CoreApp.isOnline()) { |                 if (!CoreNetwork.isOnline()) { | ||||||
|                     // Allow navigating to non-cached months in offline (behave as if using emergency cache).
 |                     // Allow navigating to non-cached months in offline (behave as if using emergency cache).
 | ||||||
|                     result = await AddonCalendarHelper.getOfflineMonthWeeks(year, monthNumber); |                     result = await AddonCalendarHelper.getOfflineMonthWeeks(year, monthNumber); | ||||||
|                 } else { |                 } else { | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; | import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; | ||||||
| import { IonRefresher } from '@ionic/angular'; | import { IonRefresher } from '@ionic/angular'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreEventObserver, CoreEvents } from '@singletons/events'; | import { CoreEventObserver, CoreEvents } from '@singletons/events'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| @ -183,7 +183,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy { | |||||||
|         this.onlineObserver = Network.onChange().subscribe(() => { |         this.onlineObserver = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             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> { |     async fetchData(sync?: boolean): Promise<void> { | ||||||
|         this.syncIcon = CoreConstants.ICON_LOADING; |         this.syncIcon = CoreConstants.ICON_LOADING; | ||||||
|         this.isOnline = CoreApp.isOnline(); |         this.isOnline = CoreNetwork.isOnline(); | ||||||
| 
 | 
 | ||||||
|         if (sync) { |         if (sync) { | ||||||
|             await this.sync(); |             await this.sync(); | ||||||
| @ -674,7 +674,7 @@ class AddonCalendarDaySlidesItemsManagerSource extends CoreSwipeSlidesDynamicIte | |||||||
|             ); |             ); | ||||||
|         } catch (error) { |         } catch (error) { | ||||||
|             // Allow navigating to non-cached days in offline (behave as if using emergency cache).
 |             // Allow navigating to non-cached days in offline (behave as if using emergency cache).
 | ||||||
|             if (CoreApp.isOnline()) { |             if (CoreNetwork.isOnline()) { | ||||||
|                 throw error; |                 throw error; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ import { | |||||||
| import { AddonCalendarEventReminder, AddonCalendarHelper } from '../../services/calendar-helper'; | import { AddonCalendarEventReminder, AddonCalendarHelper } from '../../services/calendar-helper'; | ||||||
| import { AddonCalendarOffline } from '../../services/calendar-offline'; | import { AddonCalendarOffline } from '../../services/calendar-offline'; | ||||||
| import { AddonCalendarSync, AddonCalendarSyncEvents, AddonCalendarSyncProvider } from '../../services/calendar-sync'; | 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 { CoreEventObserver, CoreEvents } from '@singletons/events'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| @ -126,7 +126,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { | |||||||
|         this.onlineObserver = Network.onChange().subscribe(() => { |         this.onlineObserver = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             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. |      * @return Promise resolved when done. | ||||||
|      */ |      */ | ||||||
|     async fetchEvent(sync = false, showErrors = false): Promise<void> { |     async fetchEvent(sync = false, showErrors = false): Promise<void> { | ||||||
|         this.isOnline = CoreApp.isOnline(); |         this.isOnline = CoreNetwork.isOnline(); | ||||||
| 
 | 
 | ||||||
|         if (sync) { |         if (sync) { | ||||||
|             const deleted = await this.syncEvents(showErrors); |             const deleted = await this.syncEvents(showErrors); | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; | import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; | ||||||
| import { IonRefresher } from '@ionic/angular'; | import { IonRefresher } from '@ionic/angular'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreEventObserver, CoreEvents } from '@singletons/events'; | import { CoreEventObserver, CoreEvents } from '@singletons/events'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| @ -156,7 +156,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy { | |||||||
|         this.onlineObserver = Network.onChange().subscribe(() => { |         this.onlineObserver = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             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> { |     async fetchData(sync?: boolean, showErrors?: boolean): Promise<void> { | ||||||
| 
 | 
 | ||||||
|         this.syncIcon = CoreConstants.ICON_LOADING; |         this.syncIcon = CoreConstants.ICON_LOADING; | ||||||
|         this.isOnline = CoreApp.isOnline(); |         this.isOnline = CoreNetwork.isOnline(); | ||||||
| 
 | 
 | ||||||
|         if (sync) { |         if (sync) { | ||||||
|             // Try to synchronize offline events.
 |             // Try to synchronize offline events.
 | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreSyncBaseProvider, CoreSyncBlockedError } from '@classes/base-sync'; | import { CoreSyncBaseProvider, CoreSyncBlockedError } from '@classes/base-sync'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreEvents } from '@singletons/events'; | import { CoreEvents } from '@singletons/events'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | 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), []); |         const eventIds: number[] = await CoreUtils.ignoreErrors(AddonCalendarOffline.getAllEventsIds(siteId), []); | ||||||
| 
 | 
 | ||||||
|         if (eventIds.length > 0) { |         if (eventIds.length > 0) { | ||||||
|             if (!CoreApp.isOnline()) { |             if (!CoreNetwork.isOnline()) { | ||||||
|                 // Cannot sync in offline.
 |                 // Cannot sync in offline.
 | ||||||
|                 throw new CoreNetworkError(); |                 throw new CoreNetworkError(); | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { CoreTimeUtils } from '@services/utils/time'; | import { CoreTimeUtils } from '@services/utils/time'; | ||||||
| import { CoreUrlUtils } from '@services/utils/url'; | import { CoreUrlUtils } from '@services/utils/url'; | ||||||
| @ -241,7 +241,7 @@ export class AddonCalendarProvider { | |||||||
|         const storeOffline = (): Promise<boolean> => |         const storeOffline = (): Promise<boolean> => | ||||||
|             AddonCalendarOffline.markDeleted(eventId, name, deleteAll, siteId).then(() => false); |             AddonCalendarOffline.markDeleted(eventId, name, deleteAll, siteId).then(() => false); | ||||||
| 
 | 
 | ||||||
|         if (forceOffline || !CoreApp.isOnline()) { |         if (forceOffline || !CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             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.
 |         // 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); |             CoreConfig.set(AddonCalendarProvider.STARTING_WEEK_DAY, response.daynames[0].dayno); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -1707,7 +1707,7 @@ export class AddonCalendarProvider { | |||||||
|             return { sent: false, event }; |             return { sent: false, event }; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (options.forceOffline || !CoreApp.isOnline()) { |         if (options.forceOffline || !CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the event.
 |             // App is offline, store the event.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -20,7 +20,6 @@ import { | |||||||
|     AddonMessages, |     AddonMessages, | ||||||
| } from '../../services/messages'; | } from '../../services/messages'; | ||||||
| import { CoreUser } from '@features/user/services/user'; | import { CoreUser } from '@features/user/services/user'; | ||||||
| import { CoreApp } from '@services/app'; |  | ||||||
| import { CoreConfig } from '@services/config'; | import { CoreConfig } from '@services/config'; | ||||||
| import { CoreEvents } from '@singletons/events'; | import { CoreEvents } from '@singletons/events'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| @ -28,6 +27,7 @@ import { CoreDomUtils } from '@services/utils/dom'; | |||||||
| import { CoreConstants } from '@/core/constants'; | import { CoreConstants } from '@/core/constants'; | ||||||
| import { IonRefresher } from '@ionic/angular'; | import { IonRefresher } from '@ionic/angular'; | ||||||
| import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications'; | import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Page that displays the messages settings page. |  * Page that displays the messages settings page. | ||||||
| @ -66,7 +66,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     protected async asyncInit(): Promise<void> { |     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())); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { | import { | ||||||
|     AddonMessagesOfflineConversationMessagesDBRecord, |     AddonMessagesOfflineConversationMessagesDBRecord, | ||||||
| @ -283,7 +283,7 @@ export class AddonMessagesOfflineProvider { | |||||||
|             conversationid: conversation.id, |             conversationid: conversation.id, | ||||||
|             text: message, |             text: message, | ||||||
|             timecreated: Date.now(), |             timecreated: Date.now(), | ||||||
|             deviceoffline: CoreApp.isOnline() ? 0 : 1, |             deviceoffline: CoreNetwork.isOnline() ? 0 : 1, | ||||||
|             conversation: JSON.stringify({ |             conversation: JSON.stringify({ | ||||||
|                 name: conversation.name || '', |                 name: conversation.name || '', | ||||||
|                 subname: conversation.subname || '', |                 subname: conversation.subname || '', | ||||||
| @ -314,7 +314,7 @@ export class AddonMessagesOfflineProvider { | |||||||
|             useridfrom: site.getUserId(), |             useridfrom: site.getUserId(), | ||||||
|             smallmessage: message, |             smallmessage: message, | ||||||
|             timecreated: new Date().getTime(), |             timecreated: new Date().getTime(), | ||||||
|             deviceoffline: CoreApp.isOnline() ? 0 : 1, |             deviceoffline: CoreNetwork.isOnline() ? 0 : 1, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         await site.getDb().insertRecord(MESSAGES_TABLE, entry); |         await site.getDb().insertRecord(MESSAGES_TABLE, entry); | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ import { CoreEvents } from '@singletons/events'; | |||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { makeSingleton, Translate } from '@singletons'; | import { makeSingleton, Translate } from '@singletons'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreConstants } from '@/core/constants'; | import { CoreConstants } from '@/core/constants'; | ||||||
| import { CoreUser } from '@features/user/services/user'; | import { CoreUser } from '@features/user/services/user'; | ||||||
| import { CoreError } from '@classes/errors/error'; | import { CoreError } from '@classes/errors/error'; | ||||||
| @ -193,7 +193,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage | |||||||
|         if (!messages.length) { |         if (!messages.length) { | ||||||
|             // Nothing to sync.
 |             // Nothing to sync.
 | ||||||
|             return result; |             return result; | ||||||
|         } else if (!CoreApp.isOnline()) { |         } else if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline. Mark messages as device offline.
 |             // Cannot sync in offline. Mark messages as device offline.
 | ||||||
|             AddonMessagesOffline.setMessagesDeviceOffline(messages, true); |             AddonMessagesOffline.setMessagesDeviceOffline(messages, true); | ||||||
| 
 | 
 | ||||||
| @ -228,7 +228,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage | |||||||
|             } catch (error) { |             } catch (error) { | ||||||
|                 if (!CoreUtils.isWebServiceError(error)) { |                 if (!CoreUtils.isWebServiceError(error)) { | ||||||
|                     // Error sending, stop execution.
 |                     // Error sending, stop execution.
 | ||||||
|                     if (CoreApp.isOnline()) { |                     if (CoreNetwork.isOnline()) { | ||||||
|                         // App is online, unmark deviceoffline if marked.
 |                         // App is online, unmark deviceoffline if marked.
 | ||||||
|                         AddonMessagesOffline.setMessagesDeviceOffline(messages, false); |                         AddonMessagesOffline.setMessagesDeviceOffline(messages, false); | ||||||
|                     } |                     } | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreLogger } from '@singletons/logger'; | import { CoreLogger } from '@singletons/logger'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreUser, CoreUserBasicData } from '@features/user/services/user'; | import { CoreUser, CoreUserBasicData } from '@features/user/services/user'; | ||||||
| import { | import { | ||||||
|     AddonMessagesOffline, |     AddonMessagesOffline, | ||||||
| @ -2424,7 +2424,7 @@ export class AddonMessagesProvider { | |||||||
| 
 | 
 | ||||||
|         siteId = siteId || CoreSites.getCurrentSiteId(); |         siteId = siteId || CoreSites.getCurrentSiteId(); | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the message.
 |             // App is offline, store the message.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -2555,7 +2555,7 @@ export class AddonMessagesProvider { | |||||||
|             }; |             }; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the message.
 |             // App is offline, store the message.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -49,7 +49,7 @@ import { AddonModAssignOffline } from '../../services/assign-offline'; | |||||||
| import { CoreUser, CoreUserProfile } from '@features/user/services/user'; | import { CoreUser, CoreUserProfile } from '@features/user/services/user'; | ||||||
| import { CoreTimeUtils } from '@services/utils/time'; | import { CoreTimeUtils } from '@services/utils/time'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper'; | import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper'; | ||||||
| import { CoreLang } from '@services/lang'; | import { CoreLang } from '@services/lang'; | ||||||
| import { CoreError } from '@classes/errors/error'; | import { CoreError } from '@classes/errors/error'; | ||||||
| @ -292,7 +292,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             CoreDomUtils.showErrorModal('core.networkerrormsg', true); |             CoreDomUtils.showErrorModal('core.networkerrormsg', true); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|  | |||||||
| @ -35,7 +35,7 @@ import { | |||||||
| import { CoreSync } from '@services/sync'; | import { CoreSync } from '@services/sync'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreNetworkError } from '@classes/errors/network-error'; | import { CoreNetworkError } from '@classes/errors/network-error'; | ||||||
| import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper'; | import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper'; | ||||||
| import { AddonModAssignSubmissionDelegate } from './submission-delegate'; | import { AddonModAssignSubmissionDelegate } from './submission-delegate'; | ||||||
| @ -215,7 +215,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid | |||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ import { CoreGrades } from '@features/grades/services/grades'; | |||||||
| import { CoreTimeUtils } from '@services/utils/time'; | import { CoreTimeUtils } from '@services/utils/time'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreError } from '@classes/errors/error'; | import { CoreError } from '@classes/errors/error'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { AddonModAssignOffline } from './assign-offline'; | import { AddonModAssignOffline } from './assign-offline'; | ||||||
| import { AddonModAssignSubmissionDelegate } from './submission-delegate'; | import { AddonModAssignSubmissionDelegate } from './submission-delegate'; | ||||||
| @ -1027,7 +1027,7 @@ export class AddonModAssignProvider { | |||||||
|             return false; |             return false; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (allowOffline && !CoreApp.isOnline()) { |         if (allowOffline && !CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -1137,7 +1137,7 @@ export class AddonModAssignProvider { | |||||||
|             return false; |             return false; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (forceOffline || !CoreApp.isOnline()) { |         if (forceOffline || !CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -1234,7 +1234,7 @@ export class AddonModAssignProvider { | |||||||
|             return false; |             return false; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -25,7 +25,7 @@ import { CoreCourseModuleData } from '@features/course/services/course-helper'; | |||||||
| import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | ||||||
| import { CoreTag, CoreTagItem } from '@features/tag/services/tag'; | import { CoreTag, CoreTagItem } from '@features/tag/services/tag'; | ||||||
| import { IonRefresher } from '@ionic/angular'; | import { IonRefresher } from '@ionic/angular'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| @ -190,7 +190,7 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy { | |||||||
| 
 | 
 | ||||||
|         if (!module.contents?.length || (refresh && !contentsAlreadyLoaded)) { |         if (!module.contents?.length || (refresh && !contentsAlreadyLoaded)) { | ||||||
|             // Try to load the contents.
 |             // Try to load the contents.
 | ||||||
|             const ignoreCache = refresh && CoreApp.isOnline(); |             const ignoreCache = refresh && CoreNetwork.isOnline(); | ||||||
| 
 | 
 | ||||||
|             try { |             try { | ||||||
|                 await CoreCourse.loadModuleContents(module, undefined, undefined, false, ignoreCache); |                 await CoreCourse.loadModuleContents(module, undefined, undefined, false, ignoreCache); | ||||||
|  | |||||||
| @ -13,7 +13,7 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Component, Input, OnDestroy, OnInit } from '@angular/core'; | import { Component, Input, OnDestroy, OnInit } from '@angular/core'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { ModalController, Network, NgZone } from '@singletons'; | import { ModalController, Network, NgZone } from '@singletons'; | ||||||
| @ -40,12 +40,12 @@ export class AddonModChatUsersModalComponent implements OnInit, OnDestroy { | |||||||
|     protected onlineSubscription: Subscription; |     protected onlineSubscription: Subscription; | ||||||
| 
 | 
 | ||||||
|     constructor() { |     constructor() { | ||||||
|         this.isOnline = CoreApp.isOnline(); |         this.isOnline = CoreNetwork.isOnline(); | ||||||
|         this.currentUserId = CoreSites.getCurrentSiteUserId(); |         this.currentUserId = CoreSites.getCurrentSiteUserId(); | ||||||
|         this.onlineSubscription = Network.onChange().subscribe(() => { |         this.onlineSubscription = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             NgZone.run(() => { | ||||||
|                 this.isOnline = CoreApp.isOnline(); |                 this.isOnline = CoreNetwork.isOnline(); | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ import { CoreSendMessageFormComponent } from '@components/send-message-form/send | |||||||
| import { CanLeave } from '@guards/can-leave'; | import { CanLeave } from '@guards/can-leave'; | ||||||
| import { IonContent } from '@ionic/angular'; | import { IonContent } from '@ionic/angular'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| @ -65,11 +66,11 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave { | |||||||
| 
 | 
 | ||||||
|     constructor() { |     constructor() { | ||||||
|         this.currentUserId = CoreSites.getCurrentSiteUserId(); |         this.currentUserId = CoreSites.getCurrentSiteUserId(); | ||||||
|         this.isOnline = CoreApp.isOnline(); |         this.isOnline = CoreNetwork.isOnline(); | ||||||
|         this.onlineSubscription = Network.onChange().subscribe(() => { |         this.onlineSubscription = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             NgZone.run(() => { | ||||||
|                 this.isOnline = CoreApp.isOnline(); |                 this.isOnline = CoreNetwork.isOnline(); | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import { CoreNetworkError } from '@classes/errors/network-error'; | |||||||
| import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; | import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; | ||||||
| import { CoreCourse } from '@features/course/services/course'; | import { CoreCourse } from '@features/course/services/course'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| @ -160,7 +160,7 @@ export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvid | |||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ import { CoreWSError } from '@classes/errors/wserror'; | |||||||
| import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | ||||||
| import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-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 { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; | import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -90,7 +90,7 @@ export class AddonModChoiceProvider { | |||||||
|             return false; |             return false; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -407,7 +407,7 @@ export class AddonModChoiceProvider { | |||||||
|             return false; |             return false; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | |||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader'; | import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader'; | ||||||
| import { CoreRatingSync } from '@features/rating/services/rating-sync'; | 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 { CoreFileEntry } from '@services/file-helper'; | ||||||
| import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreSync } from '@services/sync'; | import { CoreSync } from '@services/sync'; | ||||||
| @ -184,7 +184,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider | |||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | |||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreRatingInfo } from '@features/rating/services/rating'; | import { CoreRatingInfo } from '@features/rating/services/rating'; | ||||||
| import { CoreTagItem } from '@features/tag/services/tag'; | import { CoreTagItem } from '@features/tag/services/tag'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreFileEntry } from '@services/file-helper'; | import { CoreFileEntry } from '@services/file-helper'; | ||||||
| import { CoreFilepool } from '@services/filepool'; | import { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| @ -136,7 +136,7 @@ export class AddonModDataProvider { | |||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         // Checks to store offline.
 |         // Checks to store offline.
 | ||||||
|         if (!CoreApp.isOnline() || forceOffline) { |         if (!CoreNetwork.isOnline() || forceOffline) { | ||||||
|             const notifications = this.checkFields(fields, contents); |             const notifications = this.checkFields(fields, contents); | ||||||
|             if (notifications.length > 0) { |             if (notifications.length > 0) { | ||||||
|                 return { fieldnotifications: notifications }; |                 return { fieldnotifications: notifications }; | ||||||
| @ -147,7 +147,7 @@ export class AddonModDataProvider { | |||||||
|         await this.deleteEntryOfflineAction(dataId, entryId, AddonModDataAction.ADD, siteId); |         await this.deleteEntryOfflineAction(dataId, entryId, AddonModDataAction.ADD, siteId); | ||||||
| 
 | 
 | ||||||
|         // App is offline, store the action.
 |         // App is offline, store the action.
 | ||||||
|         if (!CoreApp.isOnline() || forceOffline) { |         if (!CoreNetwork.isOnline() || forceOffline) { | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -234,7 +234,7 @@ export class AddonModDataProvider { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -333,7 +333,7 @@ export class AddonModDataProvider { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -436,7 +436,7 @@ export class AddonModDataProvider { | |||||||
|             }; |             }; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline() || forceOffline) { |         if (!CoreNetwork.isOnline() || forceOffline) { | ||||||
|             const notifications = this.checkFields(fields, contents); |             const notifications = this.checkFields(fields, contents); | ||||||
|             if (notifications.length > 0) { |             if (notifications.length > 0) { | ||||||
|                 return { fieldnotifications: notifications }; |                 return { fieldnotifications: notifications }; | ||||||
| @ -446,7 +446,7 @@ export class AddonModDataProvider { | |||||||
|         // Remove unnecessary not synced actions.
 |         // Remove unnecessary not synced actions.
 | ||||||
|         await this.deleteEntryOfflineAction(dataId, entryId, AddonModDataAction.EDIT, siteId); |         await this.deleteEntryOfflineAction(dataId, entryId, AddonModDataAction.EDIT, siteId); | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline() || forceOffline) { |         if (!CoreNetwork.isOnline() || forceOffline) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ import { CoreCourse, CoreCourseCommonModWSOptions } from '@features/course/servi | |||||||
| import { CoreCourseModuleData } from '@features/course/services/course-helper'; | import { CoreCourseModuleData } from '@features/course/services/course-helper'; | ||||||
| import { CanLeave } from '@guards/can-leave'; | import { CanLeave } from '@guards/can-leave'; | ||||||
| import { IonContent } from '@ionic/angular'; | import { IonContent } from '@ionic/angular'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| @ -83,7 +83,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave { | |||||||
|         this.onlineObserver = Network.onChange().subscribe(() => { |         this.onlineObserver = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             NgZone.run(() => { | ||||||
|                 this.offline = !CoreApp.isOnline(); |                 this.offline = !CoreNetwork.isOnline(); | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| @ -160,7 +160,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave { | |||||||
|         try { |         try { | ||||||
|             this.module = await CoreCourse.getModule(this.cmId, this.courseId, undefined, true, false, this.currentSite.getId()); |             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 = { |             const options = { | ||||||
|                 cmId: this.cmId, |                 cmId: this.cmId, | ||||||
|                 readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK, |                 readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK, | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ import { CoreNetworkError } from '@classes/errors/network-error'; | |||||||
| import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; | import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; | ||||||
| import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course'; | import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | 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 { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreSync } from '@services/sync'; | import { CoreSync } from '@services/sync'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -174,7 +174,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv | |||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import { CoreError } from '@classes/errors/error'; | |||||||
| import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | ||||||
| import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-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 { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -1187,7 +1187,7 @@ export class AddonModFeedbackProvider { | |||||||
|             return response; |             return response; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Component, Input, OnInit } from '@angular/core'; | import { Component, Input, OnInit } from '@angular/core'; | ||||||
| import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | 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 { AddonModForum, AddonModForumPost } from '@addons/mod/forum/services/forum'; | ||||||
| import { PopoverController } from '@singletons'; | import { PopoverController } from '@singletons'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| @ -101,7 +101,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit { | |||||||
|      */ |      */ | ||||||
|     deletePost(): void { |     deletePost(): void { | ||||||
|         if (!this.offlinePost) { |         if (!this.offlinePost) { | ||||||
|             if (!CoreApp.isOnline()) { |             if (!CoreNetwork.isOnline()) { | ||||||
|                 CoreDomUtils.showErrorModal(new CoreNetworkError()); |                 CoreDomUtils.showErrorModal(new CoreNetworkError()); | ||||||
| 
 | 
 | ||||||
|                 return; |                 return; | ||||||
| @ -117,7 +117,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit { | |||||||
|      * Edit a post. |      * Edit a post. | ||||||
|      */ |      */ | ||||||
|     editPost(): void { |     editPost(): void { | ||||||
|         if (!this.offlinePost && !CoreApp.isOnline()) { |         if (!this.offlinePost && !CoreNetwork.isOnline()) { | ||||||
|             CoreDomUtils.showErrorModal(new CoreNetworkError()); |             CoreDomUtils.showErrorModal(new CoreNetworkError()); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ import { CoreRatingSyncProvider } from '@features/rating/services/rating-sync'; | |||||||
| import { CoreUser } from '@features/user/services/user'; | import { CoreUser } from '@features/user/services/user'; | ||||||
| import { CanLeave } from '@guards/can-leave'; | import { CanLeave } from '@guards/can-leave'; | ||||||
| import { IonContent, IonRefresher } from '@ionic/angular'; | import { IonContent, IonRefresher } from '@ionic/angular'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreScreen } from '@services/screen'; | import { CoreScreen } from '@services/screen'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| @ -164,12 +164,12 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         this.isOnline = CoreApp.isOnline(); |         this.isOnline = CoreNetwork.isOnline(); | ||||||
|         this.externalUrl = CoreSites.getCurrentSite()?.createSiteUrl('/mod/forum/discuss.php', { d: this.discussionId.toString() }); |         this.externalUrl = CoreSites.getCurrentSite()?.createSiteUrl('/mod/forum/discuss.php', { d: this.discussionId.toString() }); | ||||||
|         this.onlineObserver = Network.onChange().subscribe(() => { |         this.onlineObserver = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             NgZone.run(() => { | ||||||
|                 this.isOnline = CoreApp.isOnline(); |                 this.isOnline = CoreNetwork.isOnline(); | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; | |||||||
| import { FileEntry } from '@ionic-native/file/ngx'; | import { FileEntry } from '@ionic-native/file/ngx'; | ||||||
| import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader'; | import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader'; | ||||||
| import { CoreUser } from '@features/user/services/user'; | import { CoreUser } from '@features/user/services/user'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreFile } from '@services/file'; | import { CoreFile } from '@services/file'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreTimeUtils } from '@services/utils/time'; | import { CoreTimeUtils } from '@services/utils/time'; | ||||||
| @ -124,7 +124,7 @@ export class AddonModForumHelperProvider { | |||||||
|             await AddonModForumOffline.deleteNewDiscussion(forumId, timeCreated, siteId); |             await AddonModForumOffline.deleteNewDiscussion(forumId, timeCreated, siteId); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (saveOffline || !CoreApp.isOnline()) { |         if (saveOffline || !CoreNetwork.isOnline()) { | ||||||
|             await storeOffline(); |             await storeOffline(); | ||||||
| 
 | 
 | ||||||
|             return null; |             return null; | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/act | |||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreFileUploader } from '@features/fileuploader/services/fileuploader'; | import { CoreFileUploader } from '@features/fileuploader/services/fileuploader'; | ||||||
| import { CoreRatingSync } from '@features/rating/services/rating-sync'; | import { CoreRatingSync } from '@features/rating/services/rating-sync'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreGroups } from '@services/groups'; | import { CoreGroups } from '@services/groups'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreSync } from '@services/sync'; | import { CoreSync } from '@services/sync'; | ||||||
| @ -230,7 +230,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide | |||||||
|                 [] as AddonModForumOfflineDiscussion[], |                 [] as AddonModForumOfflineDiscussion[], | ||||||
|             ); |             ); | ||||||
| 
 | 
 | ||||||
|             if (discussions.length !== 0 && !CoreApp.isOnline()) { |             if (discussions.length !== 0 && !CoreNetwork.isOnline()) { | ||||||
|                 throw new Error('cannot sync in offline'); |                 throw new Error('cannot sync in offline'); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -369,7 +369,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide | |||||||
|         if (!replies.length) { |         if (!replies.length) { | ||||||
|             // Nothing to sync.
 |             // Nothing to sync.
 | ||||||
|             return { warnings: [], updated: false }; |             return { warnings: [], updated: false }; | ||||||
|         } else if (!CoreApp.isOnline()) { |         } else if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             return Promise.reject(null); |             return Promise.reject(null); | ||||||
|         } |         } | ||||||
| @ -458,7 +458,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide | |||||||
|                 [] as AddonModForumOfflineReply[], |                 [] as AddonModForumOfflineReply[], | ||||||
|             ); |             ); | ||||||
| 
 | 
 | ||||||
|             if (replies.length !== 0 && !CoreApp.isOnline()) { |             if (replies.length !== 0 && !CoreNetwork.isOnline()) { | ||||||
|                 throw new Error('Cannot sync in offline'); |                 throw new Error('Cannot sync in offline'); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | |||||||
| import { CoreRatingInfo } from '@features/rating/services/rating'; | import { CoreRatingInfo } from '@features/rating/services/rating'; | ||||||
| import { CoreTagItem } from '@features/tag/services/tag'; | import { CoreTagItem } from '@features/tag/services/tag'; | ||||||
| import { CoreUser } from '@features/user/services/user'; | import { CoreUser } from '@features/user/services/user'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreFileEntry } from '@services/file-helper'; | import { CoreFileEntry } from '@services/file-helper'; | ||||||
| import { CoreGroups } from '@services/groups'; | import { CoreGroups } from '@services/groups'; | ||||||
| import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| @ -756,7 +756,7 @@ export class AddonModForumProvider { | |||||||
|         } catch (error) { |         } catch (error) { | ||||||
|             // Try to get the data from cache stored with the old WS method.
 |             // Try to get the data from cache stored with the old WS method.
 | ||||||
|             if ( |             if ( | ||||||
|                 CoreApp.isOnline() || |                 CoreNetwork.isOnline() || | ||||||
|                 method !== 'mod_forum_get_forum_discussions' || |                 method !== 'mod_forum_get_forum_discussions' || | ||||||
|                 options.sortOrder !== AddonModForumProvider.SORTORDER_LASTPOST_DESC |                 options.sortOrder !== AddonModForumProvider.SORTORDER_LASTPOST_DESC | ||||||
|             ) { |             ) { | ||||||
| @ -1065,7 +1065,7 @@ export class AddonModForumProvider { | |||||||
|             return false; |             return false; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline() && allowOffline) { |         if (!CoreNetwork.isOnline() && allowOffline) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ import { CoreNetworkError } from '@classes/errors/network-error'; | |||||||
| import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; | import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreRatingSync } from '@features/rating/services/rating-sync'; | import { CoreRatingSync } from '@features/rating/services/rating-sync'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreSync } from '@services/sync'; | import { CoreSync } from '@services/sync'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -189,7 +189,7 @@ export class AddonModGlossarySyncProvider extends CoreCourseActivitySyncBaseProv | |||||||
|             await CoreUtils.ignoreErrors(this.setSyncTime(syncId, siteId)); |             await CoreUtils.ignoreErrors(this.setSyncTime(syncId, siteId)); | ||||||
| 
 | 
 | ||||||
|             return result; |             return result; | ||||||
|         } else if (!CoreApp.isOnline()) { |         } else if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | |||||||
| import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader'; | import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader'; | ||||||
| import { CoreRatingInfo } from '@features/rating/services/rating'; | import { CoreRatingInfo } from '@features/rating/services/rating'; | ||||||
| import { CoreTagItem } from '@features/tag/services/tag'; | 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 { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; | import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; | ||||||
| @ -898,7 +898,7 @@ export class AddonModGlossaryProvider { | |||||||
|             return false; |             return false; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline() && otherOptions.allowOffline) { |         if (!CoreNetwork.isOnline() && otherOptions.allowOffline) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ import { CoreH5PHelper } from '@features/h5p/classes/helper'; | |||||||
| import { CoreH5P } from '@features/h5p/services/h5p'; | import { CoreH5P } from '@features/h5p/services/h5p'; | ||||||
| import { CoreXAPIOffline } from '@features/xapi/services/offline'; | import { CoreXAPIOffline } from '@features/xapi/services/offline'; | ||||||
| import { CoreXAPI } from '@features/xapi/services/xapi'; | import { CoreXAPI } from '@features/xapi/services/xapi'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreFilepool } from '@services/filepool'; | import { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreSites } from '@services/sites'; | 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.
 |             // Cannot download the file or already downloaded, play the package directly.
 | ||||||
|             this.play(); |             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)) { |                     this.deployedFile?.filesize && CoreFilepool.shouldDownload(this.deployedFile.filesize)) { | ||||||
|             // Package is small, download it automatically. Don't block this function for this.
 |             // Package is small, download it automatically. Don't block this function for this.
 | ||||||
|             this.downloadAutomatically(); |             this.downloadAutomatically(); | ||||||
| @ -280,7 +280,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             CoreDomUtils.showErrorModal('core.networkerrormsg', true); |             CoreDomUtils.showErrorModal('core.networkerrormsg', true); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/act | |||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreXAPIOffline } from '@features/xapi/services/offline'; | import { CoreXAPIOffline } from '@features/xapi/services/offline'; | ||||||
| import { CoreXAPI } from '@features/xapi/services/xapi'; | import { CoreXAPI } from '@features/xapi/services/xapi'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| @ -103,7 +103,7 @@ export class AddonModH5PActivitySyncProvider extends CoreCourseActivitySyncBaseP | |||||||
|     syncActivity(contextId: number, siteId?: string): Promise<AddonModH5PActivitySyncResult> { |     syncActivity(contextId: number, siteId?: string): Promise<AddonModH5PActivitySyncResult> { | ||||||
|         siteId = siteId || CoreSites.getCurrentSiteId(); |         siteId = siteId || CoreSites.getCurrentSiteId(); | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ import { CoreCourse } from '@features/course/services/course'; | |||||||
| import { CoreCourseModuleData } from '@features/course/services/course-helper'; | import { CoreCourseModuleData } from '@features/course/services/course-helper'; | ||||||
| import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | ||||||
| import { IonRefresher } from '@ionic/angular'; | import { IonRefresher } from '@ionic/angular'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| @ -189,7 +189,7 @@ export class AddonModImscpViewPage implements OnInit { | |||||||
| 
 | 
 | ||||||
|         if (!module.contents?.length || (refresh && !contentsAlreadyLoaded)) { |         if (!module.contents?.length || (refresh && !contentsAlreadyLoaded)) { | ||||||
|             // Try to load the contents.
 |             // Try to load the contents.
 | ||||||
|             const ignoreCache = refresh && CoreApp.isOnline(); |             const ignoreCache = refresh && CoreNetwork.isOnline(); | ||||||
| 
 | 
 | ||||||
|             try { |             try { | ||||||
|                 await CoreCourse.loadModuleContents(module, undefined, undefined, false, ignoreCache); |                 await CoreCourse.loadModuleContents(module, undefined, undefined, false, ignoreCache); | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | |||||||
| import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course'; | import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course'; | ||||||
| import { CoreCourseModuleData } from '@features/course/services/course-helper'; | import { CoreCourseModuleData } from '@features/course/services/course-helper'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-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 { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreSitesCommonWSOptions, CoreSites } from '@services/sites'; | import { CoreSitesCommonWSOptions, CoreSites } from '@services/sites'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| @ -181,7 +181,7 @@ export class AddonModImscpProvider { | |||||||
|             return CoreText.concatenatePaths(dirPath, itemHref); |             return CoreText.concatenatePaths(dirPath, itemHref); | ||||||
|         } catch (error) { |         } catch (error) { | ||||||
|             // Error getting directory, there was an error downloading or we're in browser. Return online URL if connected.
 |             // 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 contents = await CoreCourse.getModuleContents(module); | ||||||
| 
 | 
 | ||||||
|                 const indexUrl = this.getFileUrlFromContents(contents, itemHref); |                 const indexUrl = this.getFileUrlFromContents(contents, itemHref); | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ import { IonContent } from '@ionic/angular'; | |||||||
| 
 | 
 | ||||||
| import { CoreError } from '@classes/errors/error'; | import { CoreError } from '@classes/errors/error'; | ||||||
| import { CanLeave } from '@guards/can-leave'; | import { CanLeave } from '@guards/can-leave'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreSync } from '@services/sync'; | 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.
 |             // If lesson has offline data already, use offline mode.
 | ||||||
|             this.offline = await AddonModLessonOffline.hasOfflineData(this.lesson.id); |             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.
 |                 // Lesson doesn't have offline data, but it allows offline and the device is offline. Use offline mode.
 | ||||||
|                 this.offline = true; |                 this.offline = true; | ||||||
|             } |             } | ||||||
| @ -375,7 +375,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { | |||||||
|     protected async finishRetake(outOfTime?: boolean): Promise<void> { |     protected async finishRetake(outOfTime?: boolean): Promise<void> { | ||||||
|         this.messages = []; |         this.messages = []; | ||||||
| 
 | 
 | ||||||
|         if (this.offline && CoreApp.isOnline()) { |         if (this.offline && CoreNetwork.isOnline()) { | ||||||
|             // Offline mode but the app is online. Try to sync the data.
 |             // Offline mode but the app is online. Try to sync the data.
 | ||||||
|             const result = await CoreUtils.ignoreErrors( |             const result = await CoreUtils.ignoreErrors( | ||||||
|                 AddonModLessonSync.syncLesson(this.lesson!.id, true, true), |                 AddonModLessonSync.syncLesson(this.lesson!.id, true, true), | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ import { CoreNetworkError } from '@classes/errors/network-error'; | |||||||
| import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; | import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; | ||||||
| import { CoreCourse } from '@features/course/services/course'; | import { CoreCourse } from '@features/course/services/course'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | 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 { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreSync } from '@services/sync'; | import { CoreSync } from '@services/sync'; | ||||||
| import { CoreTimeUtils } from '@services/utils/time'; | import { CoreTimeUtils } from '@services/utils/time'; | ||||||
| @ -275,7 +275,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid | |||||||
| 
 | 
 | ||||||
|         if (!attempts.length) { |         if (!attempts.length) { | ||||||
|             return; |             return; | ||||||
|         } else if (!CoreApp.isOnline()) { |         } else if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
| @ -420,7 +420,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid | |||||||
|             await AddonModLessonOffline.deleteRetake(lessonId, siteId); |             await AddonModLessonOffline.deleteRetake(lessonId, siteId); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|         } else if (!CoreApp.isOnline()) { |         } else if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -17,8 +17,8 @@ import { Injectable } from '@angular/core'; | |||||||
| import { CoreError } from '@classes/errors/error'; | import { CoreError } from '@classes/errors/error'; | ||||||
| import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreApp } from '@services/app'; |  | ||||||
| import { CoreFile } from '@services/file'; | import { CoreFile } from '@services/file'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; | import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { CoreUrlUtils } from '@services/utils/url'; | import { CoreUrlUtils } from '@services/utils/url'; | ||||||
| @ -251,7 +251,7 @@ export class AddonModLtiProvider { | |||||||
|         // Generate launcher and open it.
 |         // Generate launcher and open it.
 | ||||||
|         const launcherUrl = await this.generateLauncher(url, params); |         const launcherUrl = await this.generateLauncher(url, params); | ||||||
| 
 | 
 | ||||||
|         if (CoreApp.isMobile()) { |         if (CorePlatform.isMobile()) { | ||||||
|             CoreUtils.openInApp(launcherUrl); |             CoreUtils.openInApp(launcherUrl); | ||||||
|         } else { |         } else { | ||||||
|             // In desktop open in browser, we found some cases where inapp caused JS issues.
 |             // In desktop open in browser, we found some cases where inapp caused JS issues.
 | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | |||||||
| import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | ||||||
| import { CoreQuestion, CoreQuestionQuestionParsed } from '@features/question/services/question'; | import { CoreQuestion, CoreQuestionQuestionParsed } from '@features/question/services/question'; | ||||||
| import { CoreQuestionDelegate } from '@features/question/services/question-delegate'; | 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 { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreSync } from '@services/sync'; | import { CoreSync } from '@services/sync'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -311,7 +311,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider | |||||||
|             return this.finishSync(siteId, quiz, courseId, warnings); |             return this.finishSync(siteId, quiz, courseId, warnings); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreError(Translate.instant('core.cannotconnect')); |             throw new CoreError(Translate.instant('core.cannotconnect')); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -20,6 +20,7 @@ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents | |||||||
| import { CoreCourse } from '@features/course/services/course'; | import { CoreCourse } from '@features/course/services/course'; | ||||||
| import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreFileHelper } from '@services/file-helper'; | import { CoreFileHelper } from '@services/file-helper'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| @ -79,13 +80,13 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource | |||||||
|         super.ngOnInit(); |         super.ngOnInit(); | ||||||
| 
 | 
 | ||||||
|         this.isIOS = CoreApp.isIOS(); |         this.isIOS = CoreApp.isIOS(); | ||||||
|         this.isOnline = CoreApp.isOnline(); |         this.isOnline = CoreNetwork.isOnline(); | ||||||
| 
 | 
 | ||||||
|         // Refresh online status when changes.
 |         // Refresh online status when changes.
 | ||||||
|         this.onlineObserver = Network.onChange().subscribe(() => { |         this.onlineObserver = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             NgZone.run(() => { | ||||||
|                 this.isOnline = CoreApp.isOnline(); |                 this.isOnline = CoreNetwork.isOnline(); | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import { Injectable } from '@angular/core'; | |||||||
| import { CoreError } from '@classes/errors/error'; | import { CoreError } from '@classes/errors/error'; | ||||||
| import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course'; | import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course'; | ||||||
| import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper'; | 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 { CoreFile } from '@services/file'; | ||||||
| import { CoreFileHelper } from '@services/file-helper'; | import { CoreFileHelper } from '@services/file-helper'; | ||||||
| import { CoreFilepool } from '@services/filepool'; | import { CoreFilepool } from '@services/filepool'; | ||||||
| @ -80,7 +80,7 @@ export class AddonModResourceHelperProvider { | |||||||
|             return CoreText.concatenatePaths(dirPath, mainFilePath); |             return CoreText.concatenatePaths(dirPath, mainFilePath); | ||||||
|         } catch (e) { |         } catch (e) { | ||||||
|             // Error getting directory, there was an error downloading or we're in browser. Return online URL.
 |             // 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.
 |                 // This URL is going to be injected in an iframe, we need this to make it work.
 | ||||||
|                 return CoreSites.getRequiredCurrentSite().checkAndFixPluginfileURL(mainFile.fileurl); |                 return CoreSites.getRequiredCurrentSite().checkAndFixPluginfileURL(mainFile.fileurl); | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -16,9 +16,9 @@ import { Injectable } from '@angular/core'; | |||||||
| import { CoreError } from '@classes/errors/error'; | import { CoreError } from '@classes/errors/error'; | ||||||
| import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler'; | import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler'; | ||||||
| import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course'; | import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course'; | ||||||
| import { CoreApp } from '@services/app'; |  | ||||||
| import { CoreFile } from '@services/file'; | import { CoreFile } from '@services/file'; | ||||||
| import { CoreFilepool } from '@services/filepool'; | import { CoreFilepool } from '@services/filepool'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| import { CoreFileSizeSum } from '@services/plugin-file-delegate'; | import { CoreFileSizeSum } from '@services/plugin-file-delegate'; | ||||||
| import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -394,7 +394,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe | |||||||
| 
 | 
 | ||||||
|         // Remove the unzipped folder.
 |         // Remove the unzipped folder.
 | ||||||
|         promises.push(CoreFile.removeDir(path).catch((error) => { |         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.
 |                 // Not found, ignore error.
 | ||||||
|             } else { |             } else { | ||||||
|                 throw error; |                 throw error; | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import { CoreNetworkError } from '@classes/errors/network-error'; | |||||||
| import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; | import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; | ||||||
| import { CoreCourse } from '@features/course/services/course'; | import { CoreCourse } from '@features/course/services/course'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| @ -168,7 +168,7 @@ export class AddonModSurveySyncProvider extends CoreCourseActivitySyncBaseProvid | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (answersNumber > 0 && data) { |         if (answersNumber > 0 && data) { | ||||||
|             if (!CoreApp.isOnline()) { |             if (!CoreNetwork.isOnline()) { | ||||||
|                 // Cannot sync in offline.
 |                 // Cannot sync in offline.
 | ||||||
|                 throw new CoreNetworkError(); |                 throw new CoreNetworkError(); | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import { CoreError } from '@classes/errors/error'; | |||||||
| import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | ||||||
| import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-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 { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; | import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -257,7 +257,7 @@ export class AddonModSurveyProvider { | |||||||
| 
 | 
 | ||||||
|         siteId = siteId || CoreSites.getCurrentSiteId(); |         siteId = siteId || CoreSites.getCurrentSiteId(); | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the message.
 |             // App is offline, store the message.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ import { CoreCourse } from '@features/course/services/course'; | |||||||
| import { CoreTag, CoreTagItem } from '@features/tag/services/tag'; | import { CoreTag, CoreTagItem } from '@features/tag/services/tag'; | ||||||
| import { CoreUser } from '@features/user/services/user'; | import { CoreUser } from '@features/user/services/user'; | ||||||
| import { IonContent } from '@ionic/angular'; | import { IonContent } from '@ionic/angular'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreGroup, CoreGroups } from '@services/groups'; | import { CoreGroup, CoreGroups } from '@services/groups'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| @ -116,13 +116,13 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|     ) { |     ) { | ||||||
|         super('AddonModLessonIndexComponent', content, courseContentsPage); |         super('AddonModLessonIndexComponent', content, courseContentsPage); | ||||||
| 
 | 
 | ||||||
|         this.isOnline = CoreApp.isOnline(); |         this.isOnline = CoreNetwork.isOnline(); | ||||||
| 
 | 
 | ||||||
|         // Refresh online status when changes.
 |         // Refresh online status when changes.
 | ||||||
|         this.onlineSubscription = Network.onChange().subscribe(() => { |         this.onlineSubscription = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             NgZone.run(() => { | ||||||
|                 this.isOnline = CoreApp.isOnline(); |                 this.isOnline = CoreNetwork.isOnline(); | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; | |||||||
| import { CoreSyncBaseProvider, CoreSyncBlockedError } from '@classes/base-sync'; | import { CoreSyncBaseProvider, CoreSyncBlockedError } from '@classes/base-sync'; | ||||||
| import { CoreNetworkError } from '@classes/errors/network-error'; | import { CoreNetworkError } from '@classes/errors/network-error'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreGroups } from '@services/groups'; | import { CoreGroups } from '@services/groups'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreSync } from '@services/sync'; | import { CoreSync } from '@services/sync'; | ||||||
| @ -224,7 +224,7 @@ export class AddonModWikiSyncProvider extends CoreSyncBaseProvider<AddonModWikiS | |||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | |||||||
| import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreTagItem } from '@features/tag/services/tag'; | import { CoreTagItem } from '@features/tag/services/tag'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -706,7 +706,7 @@ export class AddonModWikiProvider { | |||||||
|             return -1; |             return -1; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import { CoreSyncBaseProvider, CoreSyncBlockedError } from '@classes/base-sync'; | |||||||
| import { CoreNetworkError } from '@classes/errors/network-error'; | import { CoreNetworkError } from '@classes/errors/network-error'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader'; | import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreFileEntry } from '@services/file-helper'; | import { CoreFileEntry } from '@services/file-helper'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreSync } from '@services/sync'; | import { CoreSync } from '@services/sync'; | ||||||
| @ -195,7 +195,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW | |||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | |||||||
| import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; | ||||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||||
| import { CoreGradesMenuItem } from '@features/grades/services/grades-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 { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreTextFormat, defaultTextFormat } from '@services/utils/text'; | import { CoreTextFormat, defaultTextFormat } from '@services/utils/text'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -729,7 +729,7 @@ export class AddonModWorkshopProvider { | |||||||
|         // If we are editing an offline submission, discard previous first.
 |         // If we are editing an offline submission, discard previous first.
 | ||||||
|         await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.ADD, siteId); |         await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.ADD, siteId); | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline() && allowOffline) { |         if (!CoreNetwork.isOnline() && allowOffline) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -825,7 +825,7 @@ export class AddonModWorkshopProvider { | |||||||
|         // If we are editing an offline discussion, discard previous first.
 |         // If we are editing an offline discussion, discard previous first.
 | ||||||
|         await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.UPDATE, siteId); |         await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.UPDATE, siteId); | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline() && allowOffline) { |         if (!CoreNetwork.isOnline() && allowOffline) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -904,7 +904,7 @@ export class AddonModWorkshopProvider { | |||||||
|         // If we are editing an offline discussion, discard previous first.
 |         // If we are editing an offline discussion, discard previous first.
 | ||||||
|         await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.DELETE, siteId); |         await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.DELETE, siteId); | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -1173,7 +1173,7 @@ export class AddonModWorkshopProvider { | |||||||
| 
 | 
 | ||||||
|         // If we are editing an offline discussion, discard previous first.
 |         // If we are editing an offline discussion, discard previous first.
 | ||||||
|         await AddonModWorkshopOffline.deleteAssessment(workshopId, assessmentId, siteId); |         await AddonModWorkshopOffline.deleteAssessment(workshopId, assessmentId, siteId); | ||||||
|         if (!CoreApp.isOnline() && allowOffline) { |         if (!CoreNetwork.isOnline() && allowOffline) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -1251,7 +1251,7 @@ export class AddonModWorkshopProvider { | |||||||
| 
 | 
 | ||||||
|         // If we are editing an offline discussion, discard previous first.
 |         // If we are editing an offline discussion, discard previous first.
 | ||||||
|         await AddonModWorkshopOffline.deleteEvaluateSubmission(workshopId, submissionId, siteId); |         await AddonModWorkshopOffline.deleteEvaluateSubmission(workshopId, submissionId, siteId); | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -1342,7 +1342,7 @@ export class AddonModWorkshopProvider { | |||||||
| 
 | 
 | ||||||
|         // If we are editing an offline discussion, discard previous first.
 |         // If we are editing an offline discussion, discard previous first.
 | ||||||
|         await AddonModWorkshopOffline.deleteEvaluateAssessment(workshopId, assessmentId, siteId); |         await AddonModWorkshopOffline.deleteEvaluateAssessment(workshopId, assessmentId, siteId); | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; | |||||||
| import { CoreSyncBaseProvider } from '@classes/base-sync'; | import { CoreSyncBaseProvider } from '@classes/base-sync'; | ||||||
| import { CoreNetworkError } from '@classes/errors/network-error'; | import { CoreNetworkError } from '@classes/errors/network-error'; | ||||||
| import { CoreCourses } from '@features/courses/services/courses'; | import { CoreCourses } from '@features/courses/services/courses'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { Translate, makeSingleton } from '@singletons'; | import { Translate, makeSingleton } from '@singletons'; | ||||||
| @ -148,7 +148,7 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider<AddonNotesSyncR | |||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import { CoreWSError } from '@classes/errors/wserror'; | |||||||
| import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | ||||||
| import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications'; | import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications'; | ||||||
| import { CoreUser } from '@features/user/services/user'; | import { CoreUser } from '@features/user/services/user'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreWSExternalWarning } from '@services/ws'; | import { CoreWSExternalWarning } from '@services/ws'; | ||||||
| @ -58,7 +58,7 @@ export class AddonNotesProvider { | |||||||
|             return false; |             return false; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the note.
 |             // App is offline, store the note.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -161,7 +161,7 @@ export class AddonNotesProvider { | |||||||
|             return false; |             return false; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the note.
 |             // App is offline, store the note.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -14,8 +14,8 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; |  | ||||||
| import { CoreCronHandler } from '@services/cron'; | import { CoreCronHandler } from '@services/cron'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| import { CoreEvents } from '@singletons/events'; | import { CoreEvents } from '@singletons/events'; | ||||||
| @ -35,7 +35,7 @@ export class AddonNotificationsCronHandlerService implements CoreCronHandler { | |||||||
|      * @return Time between consecutive executions (in ms). |      * @return Time between consecutive executions (in ms). | ||||||
|      */ |      */ | ||||||
|     getInterval(): number { |     getInterval(): number { | ||||||
|         return CoreApp.isMobile() ? 600000 : 60000; // 1 or 10 minutes.
 |         return CorePlatform.isMobile() ? 600000 : 60000; // 1 or 10 minutes.
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; | |||||||
| import { IonRefresher } from '@ionic/angular'; | import { IonRefresher } from '@ionic/angular'; | ||||||
| import { Md5 } from 'ts-md5/dist/md5'; | import { Md5 } from 'ts-md5/dist/md5'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| @ -154,7 +154,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { | |||||||
|      * Upload a new file. |      * Upload a new file. | ||||||
|      */ |      */ | ||||||
|     async uploadFile(): Promise<void> { |     async uploadFile(): Promise<void> { | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true); |             CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|  | |||||||
| @ -32,6 +32,7 @@ import { CoreConstants } from '@/core/constants'; | |||||||
| import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins'; | import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreDom } from '@singletons/dom'; | import { CoreDom } from '@singletons/dom'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| 
 | 
 | ||||||
| const MOODLE_VERSION_PREFIX = 'version-'; | const MOODLE_VERSION_PREFIX = 'version-'; | ||||||
| const MOODLEAPP_VERSION_PREFIX = 'moodleapp-'; | const MOODLEAPP_VERSION_PREFIX = 'moodleapp-'; | ||||||
| @ -310,7 +311,7 @@ export class AppComponent implements OnInit, AfterViewInit { | |||||||
|         Network.onChange().subscribe(() => { |         Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             NgZone.run(() => { | ||||||
|                 const isOnline = CoreApp.isOnline(); |                 const isOnline = CoreNetwork.isOnline(); | ||||||
|                 const hadOfflineMessage = document.body.classList.contains('core-offline'); |                 const hadOfflineMessage = document.body.classList.contains('core-offline'); | ||||||
| 
 | 
 | ||||||
|                 document.body.classList.toggle('core-offline', !isOnline); |                 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); |         document.body.classList.toggle('core-offline', !isOnline); | ||||||
| 
 | 
 | ||||||
|         // Set StatusBar properties.
 |         // Set StatusBar properties.
 | ||||||
|  | |||||||
| @ -12,7 +12,7 @@ | |||||||
| // See the License for the specific language governing permissions and
 | // See the License for the specific language governing permissions and
 | ||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreSync } from '@services/sync'; | import { CoreSync } from '@services/sync'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| @ -272,7 +272,7 @@ export class CoreSyncBaseProvider<T = void> { | |||||||
|      * @return Resolved with siteIds selected. Rejected if offline. |      * @return Resolved with siteIds selected. Rejected if offline. | ||||||
|      */ |      */ | ||||||
|     async syncOnSites(syncFunctionLog: string, syncFunction: (siteId: string) => void, siteId?: string): Promise<void> { |     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.`; |             const message = `Cannot sync '${syncFunctionLog}' because device is offline.`; | ||||||
|             this.logger.debug(message); |             this.logger.debug(message); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -16,6 +16,7 @@ import { InAppBrowserObject, InAppBrowserOptions } from '@ionic-native/in-app-br | |||||||
| import { Md5 } from 'ts-md5/dist/md5'; | import { Md5 } from 'ts-md5/dist/md5'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreDB } from '@services/db'; | import { CoreDB } from '@services/db'; | ||||||
| import { CoreEvents } from '@singletons/events'; | import { CoreEvents } from '@singletons/events'; | ||||||
| import { CoreFile } from '@services/file'; | import { CoreFile } from '@services/file'; | ||||||
| @ -537,7 +538,7 @@ export class CoreSite { | |||||||
|         const initialToken = this.token || ''; |         const initialToken = this.token || ''; | ||||||
|         data = data || {}; |         data = data || {}; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline() && this.offlineDisabled) { |         if (!CoreNetwork.isOnline() && this.offlineDisabled) { | ||||||
|             throw new CoreError(Translate.instant('core.errorofflinedisabled')); |             throw new CoreError(Translate.instant('core.errorofflinedisabled')); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -995,7 +996,7 @@ export class CoreSite { | |||||||
|         const now = Date.now(); |         const now = Date.now(); | ||||||
|         let expirationTime: number | undefined; |         let expirationTime: number | undefined; | ||||||
| 
 | 
 | ||||||
|         preSets.omitExpires = preSets.omitExpires || preSets.forceOffline || !CoreApp.isOnline(); |         preSets.omitExpires = preSets.omitExpires || preSets.forceOffline || !CoreNetwork.isOnline(); | ||||||
| 
 | 
 | ||||||
|         if (!preSets.omitExpires) { |         if (!preSets.omitExpires) { | ||||||
|             expirationTime = entry.expirationTime + this.getExpirationDelay(preSets.updateFrequency); |             expirationTime = entry.expirationTime + this.getExpirationDelay(preSets.updateFrequency); | ||||||
| @ -1987,7 +1988,7 @@ export class CoreSite { | |||||||
|         updateFrequency = updateFrequency || CoreSite.FREQUENCY_USUALLY; |         updateFrequency = updateFrequency || CoreSite.FREQUENCY_USUALLY; | ||||||
|         let expirationDelay = this.UPDATE_FREQUENCIES[updateFrequency] || this.UPDATE_FREQUENCIES[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.
 |             // Not WiFi, increase the expiration delay a 50% to decrease the data usage in this case.
 | ||||||
|             expirationDelay *= 1.5; |             expirationDelay *= 1.5; | ||||||
|         } |         } | ||||||
| @ -2011,7 +2012,7 @@ export class CoreSite { | |||||||
|         } else if (this.tokenPluginFileWorksPromise) { |         } else if (this.tokenPluginFileWorksPromise) { | ||||||
|             // Check ongoing, use the same promise.
 |             // Check ongoing, use the same promise.
 | ||||||
|             return this.tokenPluginFileWorksPromise; |             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.
 |             // Not online, cannot check it. Assume it's working, but don't save the result.
 | ||||||
|             return Promise.resolve(true); |             return Promise.resolve(true); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ import { CoreFileUploader, CoreFileUploaderTypeList } from '@features/fileupload | |||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { Translate } from '@singletons'; | import { Translate } from '@singletons'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper'; | import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper'; | ||||||
| import { CoreFileEntry } from '@services/file-helper'; | import { CoreFileEntry } from '@services/file-helper'; | ||||||
| @ -132,7 +132,7 @@ export class CoreAttachmentsComponent implements OnInit { | |||||||
|     async add(): Promise<void> { |     async add(): Promise<void> { | ||||||
|         const allowOffline = !!this.allowOffline && this.allowOffline !== 'false'; |         const allowOffline = !!this.allowOffline && this.allowOffline !== 'false'; | ||||||
| 
 | 
 | ||||||
|         if (!allowOffline && !CoreApp.isOnline()) { |         if (!allowOffline && !CoreNetwork.isOnline()) { | ||||||
|             CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true); |             CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|  | |||||||
| @ -14,6 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Component, Input, Output, OnInit, OnDestroy, EventEmitter } from '@angular/core'; | import { Component, Input, Output, OnInit, OnDestroy, EventEmitter } from '@angular/core'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreFilepool } from '@services/filepool'; | import { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreFileHelper } from '@services/file-helper'; | import { CoreFileHelper } from '@services/file-helper'; | ||||||
| import { CorePluginFileDelegate } from '@services/plugin-file-delegate'; | import { CorePluginFileDelegate } from '@services/plugin-file-delegate'; | ||||||
| @ -197,7 +198,7 @@ export class CoreFileComponent implements OnInit, OnDestroy { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline() && (!openAfterDownload || (openAfterDownload && |         if (!CoreNetwork.isOnline() && (!openAfterDownload || (openAfterDownload && | ||||||
|                 !CoreFileHelper.isStateDownloaded(this.state)))) { |                 !CoreFileHelper.isStateDownloaded(this.state)))) { | ||||||
|             CoreDomUtils.showErrorModal('core.networkerrormsg', true); |             CoreDomUtils.showErrorModal('core.networkerrormsg', true); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -13,7 +13,6 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Component, Input, Output, EventEmitter, OnInit, ViewChild, ElementRef } from '@angular/core'; | import { Component, Input, Output, EventEmitter, OnInit, ViewChild, ElementRef } from '@angular/core'; | ||||||
| import { CoreApp } from '@services/app'; |  | ||||||
| import { CoreConfig } from '@services/config'; | import { CoreConfig } from '@services/config'; | ||||||
| import { CoreEvents } from '@singletons/events'; | import { CoreEvents } from '@singletons/events'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| @ -21,6 +20,7 @@ import { CoreUtils } from '@services/utils/utils'; | |||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { CoreConstants } from '@/core/constants'; | import { CoreConstants } from '@/core/constants'; | ||||||
| import { CoreForms } from '@singletons/form'; | import { CoreForms } from '@singletons/form'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Component to display a "send message form". |  * Component to display a "send message form". | ||||||
| @ -55,7 +55,7 @@ export class CoreSendMessageFormComponent implements OnInit { | |||||||
|         this.onSubmit = new EventEmitter(); |         this.onSubmit = new EventEmitter(); | ||||||
|         this.onResize = 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; |             this.sendOnEnter = !!sendOnEnter; | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
| @ -117,7 +117,7 @@ export class CoreSendMessageFormComponent implements OnInit { | |||||||
|             // Enter clicked, send the message.
 |             // Enter clicked, send the message.
 | ||||||
|             e.preventDefault(); |             e.preventDefault(); | ||||||
|             e.stopPropagation(); |             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.
 |             // Cmd+Enter or Ctrl+Enter, send message.
 | ||||||
|             e.preventDefault(); |             e.preventDefault(); | ||||||
|             e.stopPropagation(); |             e.stopPropagation(); | ||||||
| @ -138,7 +138,7 @@ export class CoreSendMessageFormComponent implements OnInit { | |||||||
|         if (this.sendOnEnter && !other) { |         if (this.sendOnEnter && !other) { | ||||||
|             // Enter clicked, send the message.
 |             // Enter clicked, send the message.
 | ||||||
|             this.submitForm(e); |             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.
 |             // Cmd+Enter or Ctrl+Enter, send message.
 | ||||||
|             this.submitForm(e); |             this.submitForm(e); | ||||||
|         } |         } | ||||||
|  | |||||||
							
								
								
									
										37
									
								
								src/core/components/stories/user-avatar.stories.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/core/components/stories/user-avatar.stories.ts
									
									
									
									
									
										Normal 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); | ||||||
| @ -14,12 +14,12 @@ | |||||||
| 
 | 
 | ||||||
| import { Component, Input, OnInit, OnChanges, OnDestroy, SimpleChange } from '@angular/core'; | import { Component, Input, OnInit, OnChanges, OnDestroy, SimpleChange } from '@angular/core'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; |  | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreEventObserver, CoreEvents } from '@singletons/events'; | 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 { CoreNavigator } from '@services/navigator'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Component to display a "user avatar". |  * Component to display a "user avatar". | ||||||
| @ -54,7 +54,7 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy { | |||||||
|         this.currentUserId = CoreSites.getCurrentSiteUserId(); |         this.currentUserId = CoreSites.getCurrentSiteUserId(); | ||||||
| 
 | 
 | ||||||
|         this.pictureObserver = CoreEvents.on( |         this.pictureObserver = CoreEvents.on( | ||||||
|             CoreUserProvider.PROFILE_PICTURE_UPDATED, |             USER_PROFILE_PICTURE_UPDATED, | ||||||
|             (data) => { |             (data) => { | ||||||
|                 if (data.userId == this.userId) { |                 if (data.userId == this.userId) { | ||||||
|                     this.avatarUrl = data.picture; |                     this.avatarUrl = data.picture; | ||||||
| @ -119,7 +119,7 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy { | |||||||
|             return this.user.lastaccess * 1000 >= time; |             return this.user.lastaccess * 1000 >= time; | ||||||
|         } else { |         } else { | ||||||
|             // You have to have Internet access first.
 |             // You have to have Internet access first.
 | ||||||
|             return !!this.user.isonline && CoreApp.isOnline(); |             return !!this.user.isonline && CoreNetwork.isOnline(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -34,6 +34,7 @@ import { CoreError } from '@classes/errors/error'; | |||||||
| import { CoreSite } from '@classes/site'; | import { CoreSite } from '@classes/site'; | ||||||
| import { CoreEventObserver, CoreEvents } from '@singletons/events'; | import { CoreEventObserver, CoreEvents } from '@singletons/events'; | ||||||
| import { CoreConstants } from '../constants'; | import { CoreConstants } from '../constants'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Directive to handle external content. |  * Directive to handle external content. | ||||||
| @ -427,7 +428,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges, O | |||||||
|             clickableEl.addEventListener(eventName, () => { |             clickableEl.addEventListener(eventName, () => { | ||||||
|                 // User played media or opened a downloadable link.
 |                 // User played media or opened a downloadable link.
 | ||||||
|                 // Download the file if in wifi and it hasn't been downloaded already (for big files).
 |                 // 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.
 |                     // 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); |                     CoreFilepool.getUrlByUrl(site.getId(), url, this.component, this.componentId, 0, false); | ||||||
|                 } |                 } | ||||||
|  | |||||||
| @ -40,6 +40,7 @@ import { CoreCommentsOffline } from '@features/comments/services/comments-offlin | |||||||
| import { CoreCommentsDBRecord } from '@features/comments/services/database/comments'; | import { CoreCommentsDBRecord } from '@features/comments/services/database/comments'; | ||||||
| import { CoreTimeUtils } from '@services/utils/time'; | import { CoreTimeUtils } from '@services/utils/time'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| import moment from 'moment'; | import moment from 'moment'; | ||||||
| import { Subscription } from 'rxjs'; | import { Subscription } from 'rxjs'; | ||||||
| 
 | 
 | ||||||
| @ -108,11 +109,11 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy { | |||||||
|             } |             } | ||||||
|         }, CoreSites.getCurrentSiteId()); |         }, CoreSites.getCurrentSiteId()); | ||||||
| 
 | 
 | ||||||
|         this.isOnline = CoreApp.isOnline(); |         this.isOnline = CoreNetwork.isOnline(); | ||||||
|         this.onlineObserver = Network.onChange().subscribe(() => { |         this.onlineObserver = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             NgZone.run(() => { | ||||||
|                 this.isOnline = CoreApp.isOnline(); |                 this.isOnline = CoreNetwork.isOnline(); | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ import { CoreEvents } from '@singletons/events'; | |||||||
| import { makeSingleton, Translate } from '@singletons'; | import { makeSingleton, Translate } from '@singletons'; | ||||||
| import { CoreCommentsOffline } from './comments-offline'; | import { CoreCommentsOffline } from './comments-offline'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreNetworkError } from '@classes/errors/network-error'; | import { CoreNetworkError } from '@classes/errors/network-error'; | ||||||
| import { CoreCommentsDBRecord, CoreCommentsDeletedDBRecord } from './database/comments'; | import { CoreCommentsDBRecord, CoreCommentsDeletedDBRecord } from './database/comments'; | ||||||
| @ -204,7 +204,7 @@ export class CoreCommentsSyncProvider extends CoreSyncBaseProvider<CoreCommentsS | |||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreError } from '@classes/errors/error'; | import { CoreError } from '@classes/errors/error'; | ||||||
| import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreWSExternalWarning } from '@services/ws'; | import { CoreWSExternalWarning } from '@services/ws'; | ||||||
| @ -95,7 +95,7 @@ export class CoreCommentsProvider { | |||||||
|             return false; |             return false; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the comment.
 |             // App is offline, store the comment.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
| @ -243,7 +243,7 @@ export class CoreCommentsProvider { | |||||||
|             return false; |             return false; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the comment.
 |             // App is offline, store the comment.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ | |||||||
| import { CoreConstants } from '@/core/constants'; | import { CoreConstants } from '@/core/constants'; | ||||||
| import { CoreNetworkError } from '@classes/errors/network-error'; | import { CoreNetworkError } from '@classes/errors/network-error'; | ||||||
| import { CoreFilterHelper } from '@features/filter/services/filter-helper'; | import { CoreFilterHelper } from '@features/filter/services/filter-helper'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreFilepool } from '@services/filepool'; | import { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreCourse, CoreCourseAnyModuleData } from '../services/course'; | import { CoreCourse, CoreCourseAnyModuleData } from '../services/course'; | ||||||
| @ -84,7 +84,7 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe | |||||||
|     ): Promise<void> { |     ): Promise<void> { | ||||||
|         siteId = siteId || CoreSites.getCurrentSiteId(); |         siteId = siteId || CoreSites.getCurrentSiteId(); | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot prefetch in offline.
 |             // Cannot prefetch in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ import { CoreConstants } from '@/core/constants'; | |||||||
| import { OnInit, OnDestroy, Input, Output, EventEmitter, Component, Optional, Inject } from '@angular/core'; | import { OnInit, OnDestroy, Input, Output, EventEmitter, Component, Optional, Inject } from '@angular/core'; | ||||||
| import { CoreAnyError } from '@classes/errors/error'; | import { CoreAnyError } from '@classes/errors/error'; | ||||||
| import { IonRefresher } from '@ionic/angular'; | import { IonRefresher } from '@ionic/angular'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| 
 | 
 | ||||||
| @ -354,7 +354,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, | |||||||
| 
 | 
 | ||||||
|         if (!this.module.contents?.length || (refresh && !contentsAlreadyLoaded)) { |         if (!this.module.contents?.length || (refresh && !contentsAlreadyLoaded)) { | ||||||
|             // Try to load the contents.
 |             // Try to load the contents.
 | ||||||
|             const ignoreCache = refresh && CoreApp.isOnline(); |             const ignoreCache = refresh && CoreNetwork.isOnline(); | ||||||
| 
 | 
 | ||||||
|             try { |             try { | ||||||
|                 await CoreCourse.loadModuleContents(this.module, undefined, undefined, false, ignoreCache); |                 await CoreCourse.loadModuleContents(this.module, undefined, undefined, false, ignoreCache); | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { CoreNetworkError } from '@classes/errors/network-error'; | import { CoreNetworkError } from '@classes/errors/network-error'; | ||||||
| import { CoreFilterHelper } from '@features/filter/services/filter-helper'; | import { CoreFilterHelper } from '@features/filter/services/filter-helper'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreFilepool } from '@services/filepool'; | import { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreWSFile } from '@services/ws'; | import { CoreWSFile } from '@services/ws'; | ||||||
| @ -57,7 +57,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe | |||||||
|      * @return Promise resolved when all content is downloaded. |      * @return Promise resolved when all content is downloaded. | ||||||
|      */ |      */ | ||||||
|     async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean, dirPath?: string): Promise<void> { |     async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean, dirPath?: string): Promise<void> { | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot download in offline.
 |             // Cannot download in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg | |||||||
| import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | ||||||
| import { CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses'; | import { CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses'; | ||||||
| import { CoreGradesFormattedRow, CoreGradesFormattedTableRow, CoreGradesHelper } from '@features/grades/services/grades-helper'; | 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 { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| @ -79,13 +79,13 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { | |||||||
| 
 | 
 | ||||||
|     constructor() { |     constructor() { | ||||||
|         this.siteId = CoreSites.getCurrentSiteId(); |         this.siteId = CoreSites.getCurrentSiteId(); | ||||||
|         this.isOnline = CoreApp.isOnline(); |         this.isOnline = CoreNetwork.isOnline(); | ||||||
| 
 | 
 | ||||||
|         // Refresh online status when changes.
 |         // Refresh online status when changes.
 | ||||||
|         this.onlineSubscription = Network.onChange().subscribe(() => { |         this.onlineSubscription = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             NgZone.run(() => { | ||||||
|                 this.isOnline = CoreApp.isOnline(); |                 this.isOnline = CoreNetwork.isOnline(); | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Component, Input, OnInit } from '@angular/core'; | 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'; | import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | |||||||
| @ -58,7 +58,7 @@ import { | |||||||
| } from './module-prefetch-delegate'; | } from './module-prefetch-delegate'; | ||||||
| import { CoreFileSizeSum } from '@services/plugin-file-delegate'; | import { CoreFileSizeSum } from '@services/plugin-file-delegate'; | ||||||
| import { CoreFileHelper } from '@services/file-helper'; | import { CoreFileHelper } from '@services/file-helper'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSite } from '@classes/site'; | import { CoreSite } from '@classes/site'; | ||||||
| import { CoreFile } from '@services/file'; | import { CoreFile } from '@services/file'; | ||||||
| import { CoreUrlUtils } from '@services/utils/url'; | import { CoreUrlUtils } from '@services/utils/url'; | ||||||
| @ -798,7 +798,7 @@ export class CoreCourseHelperProvider { | |||||||
|         files?: CoreCourseModuleContentFile[], |         files?: CoreCourseModuleContentFile[], | ||||||
|         options: CoreUtilsOpenFileOptions = {}, |         options: CoreUtilsOpenFileOptions = {}, | ||||||
|     ): Promise<void> { |     ): Promise<void> { | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Not online, get the offline file. It will fail if not found.
 |             // Not online, get the offline file. It will fail if not found.
 | ||||||
|             let path: string | undefined; |             let path: string | undefined; | ||||||
|             try { |             try { | ||||||
| @ -950,7 +950,7 @@ export class CoreCourseHelperProvider { | |||||||
|     ): Promise<string> { |     ): Promise<string> { | ||||||
|         siteId = siteId || CoreSites.getCurrentSiteId(); |         siteId = siteId || CoreSites.getCurrentSiteId(); | ||||||
| 
 | 
 | ||||||
|         const isOnline = CoreApp.isOnline(); |         const isOnline = CoreNetwork.isOnline(); | ||||||
|         const mainFile = files[0]; |         const mainFile = files[0]; | ||||||
|         const timemodified = mainFile.timemodified || 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.
 |         // 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); |             this.downloadModule(module, courseId, component, componentId, files, siteId); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { Params } from '@angular/router'; | import { Params } from '@angular/router'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreEvents } from '@singletons/events'; | import { CoreEvents } from '@singletons/events'; | ||||||
| import { CoreLogger } from '@singletons/logger'; | import { CoreLogger } from '@singletons/logger'; | ||||||
| import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| @ -554,7 +554,7 @@ export class CoreCourseProvider { | |||||||
|                 return sections; |                 return sections; | ||||||
|             } catch { |             } catch { | ||||||
|                 // The module might still be cached by a request with different parameters.
 |                 // The module might still be cached by a request with different parameters.
 | ||||||
|                 if (!ignoreCache && !CoreApp.isOnline()) { |                 if (!ignoreCache && !CoreNetwork.isOnline()) { | ||||||
|                     if (includeStealth) { |                     if (includeStealth) { | ||||||
|                         // Older versions didn't include the includestealthmodules option.
 |                         // Older versions didn't include the includestealthmodules option.
 | ||||||
|                         return doRequest(site, courseId, moduleId, modName, false, true); |                         return doRequest(site, courseId, moduleId, modName, false, true); | ||||||
| @ -1168,7 +1168,7 @@ export class CoreCourseProvider { | |||||||
|             CoreCourseOffline.markCompletedManually(cmId, completed, courseId, undefined, siteId); |             CoreCourseOffline.markCompletedManually(cmId, completed, courseId, undefined, siteId); | ||||||
| 
 | 
 | ||||||
|         // The offline function requires a courseId and it could be missing because it's a calculated field.
 |         // 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.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { CoreTimeUtils } from '@services/utils/time'; | 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> { |     async log(ws: string, data: Record<string, unknown>, component: string, componentId: number, siteId?: string): Promise<void> { | ||||||
|         const site = await CoreSites.getSite(siteId); |         const site = await CoreSites.getSite(siteId); | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return this.storeOffline(ws, data, component, componentId, site.getId()); |             return this.storeOffline(ws, data, component, componentId, site.getId()); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import { Injectable } from '@angular/core'; | |||||||
| import { CoreSyncBaseProvider } from '@classes/base-sync'; | import { CoreSyncBaseProvider } from '@classes/base-sync'; | ||||||
| 
 | 
 | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { CoreCourseOffline } from './course-offline'; | import { CoreCourseOffline } from './course-offline'; | ||||||
| @ -167,7 +167,7 @@ export class CoreCourseSyncProvider extends CoreSyncBaseProvider<CoreCourseSyncR | |||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -28,7 +28,6 @@ import { FormControl } from '@angular/forms'; | |||||||
| import { IonTextarea, IonContent, IonSlides } from '@ionic/angular'; | import { IonTextarea, IonContent, IonSlides } from '@ionic/angular'; | ||||||
| import { Subscription } from 'rxjs'; | import { Subscription } from 'rxjs'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; |  | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreFilepool } from '@services/filepool'; | import { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| @ -42,6 +41,7 @@ import { CoreLoadingComponent } from '@components/loading/loading'; | |||||||
| import { CoreScreen } from '@services/screen'; | import { CoreScreen } from '@services/screen'; | ||||||
| import { CoreCancellablePromise } from '@classes/cancellable-promise'; | import { CoreCancellablePromise } from '@classes/cancellable-promise'; | ||||||
| import { CoreDom } from '@singletons/dom'; | import { CoreDom } from '@singletons/dom'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Component to display a rich text editor if enabled. |  * Component to display a rich text editor if enabled. | ||||||
| @ -797,7 +797,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit, | |||||||
|         const selection = window.getSelection()?.toString(); |         const selection = window.getSelection()?.toString(); | ||||||
| 
 | 
 | ||||||
|         // When RTE is focused with a whole paragraph in desktop the stopBubble will not fire click.
 |         // 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); |             this.stopBubble(event); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -17,7 +17,6 @@ import { MediaObject } from '@ionic-native/media/ngx'; | |||||||
| import { FileEntry } from '@ionic-native/file/ngx'; | import { FileEntry } from '@ionic-native/file/ngx'; | ||||||
| import { MediaFile } from '@ionic-native/media-capture/ngx'; | import { MediaFile } from '@ionic-native/media-capture/ngx'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; |  | ||||||
| import { CoreFile, CoreFileProvider } from '@services/file'; | import { CoreFile, CoreFileProvider } from '@services/file'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreMimetypeUtils } from '@services/utils/mimetype'; | import { CoreMimetypeUtils } from '@services/utils/mimetype'; | ||||||
| @ -27,6 +26,7 @@ import { CoreError } from '@classes/errors/error'; | |||||||
| import { CoreCaptureError } from '@classes/errors/captureerror'; | import { CoreCaptureError } from '@classes/errors/captureerror'; | ||||||
| import { CoreCanceledError } from '@classes/errors/cancelederror'; | import { CoreCanceledError } from '@classes/errors/cancelederror'; | ||||||
| import { CoreText } from '@singletons/text'; | import { CoreText } from '@singletons/text'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Page to capture media in browser, or to capture audio in mobile devices. |  * 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.title = 'core.captureimage'; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         this.isCordovaAudioCapture = CoreApp.isMobile() && this.isAudio; |         this.isCordovaAudioCapture = CorePlatform.isMobile() && this.isAudio; | ||||||
| 
 | 
 | ||||||
|         if (this.isCordovaAudioCapture) { |         if (this.isCordovaAudioCapture) { | ||||||
|             this.extension = Platform.is('ios') ? 'wav' : 'aac'; |             this.extension = Platform.is('ios') ? 'wav' : 'aac'; | ||||||
|  | |||||||
| @ -20,6 +20,7 @@ import { FileEntry, IFile } from '@ionic-native/file/ngx'; | |||||||
| import { MediaFile } from '@ionic-native/media-capture/ngx'; | import { MediaFile } from '@ionic-native/media-capture/ngx'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreFile, CoreFileProvider, CoreFileProgressEvent } from '@services/file'; | import { CoreFile, CoreFileProvider, CoreFileProgressEvent } from '@services/file'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreMimetypeUtils } from '@services/utils/mimetype'; | import { CoreMimetypeUtils } from '@services/utils/mimetype'; | ||||||
| @ -37,6 +38,7 @@ import { CoreWSUploadFileResult } from '@services/ws'; | |||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreText } from '@singletons/text'; | import { CoreText } from '@singletons/text'; | ||||||
| import { CorePromisedValue } from '@classes/promised-value'; | import { CorePromisedValue } from '@classes/promised-value'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Helper service to upload files. |  * Helper service to upload files. | ||||||
| @ -121,7 +123,7 @@ export class CoreFileUploaderHelperProvider { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!allowOffline && !CoreApp.isOnline()) { |         if (!allowOffline && !CoreNetwork.isOnline()) { | ||||||
|             throw new CoreError(Translate.instant('core.fileuploader.errormustbeonlinetoupload')); |             throw new CoreError(Translate.instant('core.fileuploader.errormustbeonlinetoupload')); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -131,7 +133,7 @@ export class CoreFileUploaderHelperProvider { | |||||||
| 
 | 
 | ||||||
|         if (size < 0) { |         if (size < 0) { | ||||||
|             return CoreDomUtils.showConfirm(Translate.instant('core.fileuploader.confirmuploadunknownsize')); |             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); |             const readableSize = CoreTextUtils.bytesToSize(size, 2); | ||||||
| 
 | 
 | ||||||
|             return CoreDomUtils.showConfirm( |             return CoreDomUtils.showConfirm( | ||||||
| @ -364,7 +366,7 @@ export class CoreFileUploaderHelperProvider { | |||||||
|                         return false; |                         return false; | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|                     if (!allowOffline && !CoreApp.isOnline()) { |                     if (!allowOffline && !CoreNetwork.isOnline()) { | ||||||
|                         // Not allowed, show error.
 |                         // Not allowed, show error.
 | ||||||
|                         CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true); |                         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.
 |             media = medias[0]; // We used limit 1, we only want 1 media.
 | ||||||
|         } catch (error) { |         } 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.
 |                 // No app to record audio, fallback to capture it ourselves.
 | ||||||
|                 try { |                 try { | ||||||
|                     media = await CoreFileUploader.captureAudioInApp(); |                     media = await CoreFileUploader.captureAudioInApp(); | ||||||
| @ -574,7 +576,7 @@ export class CoreFileUploaderHelperProvider { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Make sure the path has the protocol. In iOS it doesn't.
 |         // 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; |             path = 'file://' + path; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -795,7 +797,7 @@ export class CoreFileUploaderHelperProvider { | |||||||
|             return this.uploadFile(path, maxSize, checkSize, options, siteId); |             return this.uploadFile(path, maxSize, checkSize, options, siteId); | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             return errorUploading(Translate.instant('core.fileuploader.errormustbeonlinetoupload')); |             return errorUploading(Translate.instant('core.fileuploader.errormustbeonlinetoupload')); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CorePlatform } from '@services/platform'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate'; | import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate'; | ||||||
| @ -35,7 +35,7 @@ export class CoreFileUploaderAlbumHandlerService implements CoreFileUploaderHand | |||||||
|      * @return Promise resolved with true if enabled. |      * @return Promise resolved with true if enabled. | ||||||
|      */ |      */ | ||||||
|     async isEnabled(): Promise<boolean> { |     async isEnabled(): Promise<boolean> { | ||||||
|         return CoreApp.isMobile(); |         return CorePlatform.isMobile(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -15,6 +15,7 @@ | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate'; | import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate'; | ||||||
| @ -34,7 +35,7 @@ export class CoreFileUploaderAudioHandlerService implements CoreFileUploaderHand | |||||||
|      * @return Promise resolved with true if enabled. |      * @return Promise resolved with true if enabled. | ||||||
|      */ |      */ | ||||||
|     async isEnabled(): Promise<boolean> { |     async isEnabled(): Promise<boolean> { | ||||||
|         return CoreApp.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia()); |         return CorePlatform.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -15,6 +15,7 @@ | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate'; | import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate'; | ||||||
| @ -35,7 +36,7 @@ export class CoreFileUploaderCameraHandlerService implements CoreFileUploaderHan | |||||||
|      * @return Promise resolved with true if enabled. |      * @return Promise resolved with true if enabled. | ||||||
|      */ |      */ | ||||||
|     async isEnabled(): Promise<boolean> { |     async isEnabled(): Promise<boolean> { | ||||||
|         return CoreApp.isMobile() || CoreApp.canGetUserMedia(); |         return CorePlatform.isMobile() || CoreApp.canGetUserMedia(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -20,6 +20,7 @@ import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderH | |||||||
| import { CoreFileUploaderHelper } from '../fileuploader-helper'; | import { CoreFileUploaderHelper } from '../fileuploader-helper'; | ||||||
| import { CoreFileUploader } from '../fileuploader'; | import { CoreFileUploader } from '../fileuploader'; | ||||||
| import { makeSingleton, Translate } from '@singletons'; | import { makeSingleton, Translate } from '@singletons'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Handler to upload any type of file. |  * 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.
 |             icon: 'folder', // Cannot use font-awesome in action sheet.
 | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (CoreApp.isMobile()) { |         if (CorePlatform.isMobile()) { | ||||||
|             handler.action = async ( |             handler.action = async ( | ||||||
|                 maxSize?: number, |                 maxSize?: number, | ||||||
|                 upload?: boolean, |                 upload?: boolean, | ||||||
|  | |||||||
| @ -15,6 +15,7 @@ | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate'; | import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate'; | ||||||
| @ -34,7 +35,7 @@ export class CoreFileUploaderVideoHandlerService implements CoreFileUploaderHand | |||||||
|      * @return Promise resolved with true if enabled. |      * @return Promise resolved with true if enabled. | ||||||
|      */ |      */ | ||||||
|     async isEnabled(): Promise<boolean> { |     async isEnabled(): Promise<boolean> { | ||||||
|         return CoreApp.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia()); |         return CorePlatform.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreFilterDelegate } from './filter-delegate'; | import { CoreFilterDelegate } from './filter-delegate'; | ||||||
| import { | import { | ||||||
| @ -299,7 +299,7 @@ export class CoreFilterHelperProvider { | |||||||
| 
 | 
 | ||||||
|         const cachedData = this.moduleContextsCache[siteId][courseId][contextLevel]; |         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.
 |             // We can use cache, return the filters if found.
 | ||||||
|             return cachedData.contexts[contextLevel] && cachedData.contexts[contextLevel][instanceId]; |             return cachedData.contexts[contextLevel] && cachedData.contexts[contextLevel][instanceId]; | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreSite } from '@classes/site'; | import { CoreSite } from '@classes/site'; | ||||||
| import { CoreWSExternalWarning } from '@services/ws'; | import { CoreWSExternalWarning } from '@services/ws'; | ||||||
| @ -338,7 +338,7 @@ export class CoreFilterProvider { | |||||||
| 
 | 
 | ||||||
|         // Check if we have the contexts in the memory cache.
 |         // Check if we have the contexts in the memory cache.
 | ||||||
|         const siteContexts = this.contextsCache[site.getId()]; |         const siteContexts = this.contextsCache[site.getId()]; | ||||||
|         const isOnline = CoreApp.isOnline(); |         const isOnline = CoreNetwork.isOnline(); | ||||||
|         const result: CoreFilterClassifiedFilters = {}; |         const result: CoreFilterClassifiedFilters = {}; | ||||||
|         let allFound = true; |         let allFound = true; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Component, Input, ElementRef, OnInit, OnDestroy, OnChanges, SimpleChange } from '@angular/core'; | 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 { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| @ -111,7 +111,7 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy { | |||||||
|      * @return Promise resolved when done. |      * @return Promise resolved when done. | ||||||
|      */ |      */ | ||||||
|     async download(): Promise<void> { |     async download(): Promise<void> { | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             CoreDomUtils.showErrorModal('core.networkerrormsg', true); |             CoreDomUtils.showErrorModal('core.networkerrormsg', true); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
| @ -144,7 +144,7 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy { | |||||||
|      */ |      */ | ||||||
|     protected async attemptDownloadInBg(): Promise<void> { |     protected async attemptDownloadInBg(): Promise<void> { | ||||||
|         if (!this.urlParams || !this.src || !this.siteCanDownload || !CoreH5P.canGetTrustedH5PFileInSite() || |         if (!this.urlParams || !this.src || !this.siteCanDownload || !CoreH5P.canGetTrustedH5PFileInSite() || | ||||||
|                 !CoreApp.isOnline()) { |                 !CoreNetwork.isOnline()) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ import { Subscription } from 'rxjs'; | |||||||
| import { debounceTime } from 'rxjs/operators'; | import { debounceTime } from 'rxjs/operators'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreLoginHelper } from '@features/login/services/login-helper'; | import { CoreLoginHelper } from '@features/login/services/login-helper'; | ||||||
| @ -244,7 +245,7 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             CoreDomUtils.showErrorModal('core.networkerrormsg', true); |             CoreDomUtils.showErrorModal('core.networkerrormsg', true); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|  | |||||||
| @ -16,6 +16,7 @@ import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/co | |||||||
| import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -201,7 +202,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             CoreDomUtils.showErrorModal('core.networkerrormsg', true); |             CoreDomUtils.showErrorModal('core.networkerrormsg', true); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|  | |||||||
| @ -16,6 +16,7 @@ import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; | |||||||
| import { FormBuilder, FormGroup, ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms'; | import { FormBuilder, FormGroup, ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms'; | ||||||
| 
 | 
 | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreConfig } from '@services/config'; | import { CoreConfig } from '@services/config'; | ||||||
| import { CoreSites, CoreSiteCheckResponse, CoreLoginSiteInfo, CoreSitesDemoSiteData } from '@services/sites'; | import { CoreSites, CoreSiteCheckResponse, CoreLoginSiteInfo, CoreSitesDemoSiteData } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -242,7 +243,7 @@ export class CoreLoginSitePage implements OnInit { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             CoreDomUtils.showErrorModal('core.networkerrormsg', true); |             CoreDomUtils.showErrorModal('core.networkerrormsg', true); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|  | |||||||
| @ -46,6 +46,7 @@ import { CoreDatabaseTable } from '@classes/database/database-table'; | |||||||
| import { CoreDatabaseCachingStrategy, CoreDatabaseTableProxy } from '@classes/database/database-table-proxy'; | import { CoreDatabaseCachingStrategy, CoreDatabaseTableProxy } from '@classes/database/database-table-proxy'; | ||||||
| import { CoreObject } from '@singletons/object'; | import { CoreObject } from '@singletons/object'; | ||||||
| import { lazyMap, LazyMap } from '@/core/utils/lazy-map'; | import { lazyMap, LazyMap } from '@/core/utils/lazy-map'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle push notifications. |  * Service to handle push notifications. | ||||||
| @ -204,7 +205,7 @@ export class CorePushNotificationsProvider { | |||||||
|      * @return Whether the device can be registered in Moodle. |      * @return Whether the device can be registered in Moodle. | ||||||
|      */ |      */ | ||||||
|     canRegisterOnMoodle(): boolean { |     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. |      * @return Promise resolved when device is unregistered. | ||||||
|      */ |      */ | ||||||
|     async unregisterDeviceOnMoodle(site: CoreSite): Promise<void> { |     async unregisterDeviceOnMoodle(site: CoreSite): Promise<void> { | ||||||
|         if (!site || !CoreApp.isMobile()) { |         if (!site || !CorePlatform.isMobile()) { | ||||||
|             throw new CoreError('Cannot unregister device'); |             throw new CoreError('Cannot unregister device'); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -624,7 +625,7 @@ export class CorePushNotificationsProvider { | |||||||
| 
 | 
 | ||||||
|         const total = counters.reduce((previous, counter) => previous + counter, 0); |         const total = counters.reduce((previous, counter) => previous + counter, 0); | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isMobile()) { |         if (!CorePlatform.isMobile()) { | ||||||
|             // Browser doesn't have an app badge, stop.
 |             // Browser doesn't have an app badge, stop.
 | ||||||
|             return total; |             return total; | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ import { ContextLevel } from '@/core/constants'; | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreSyncBaseProvider } from '@classes/base-sync'; | import { CoreSyncBaseProvider } from '@classes/base-sync'; | ||||||
| import { CoreNetworkError } from '@classes/errors/network-error'; | import { CoreNetworkError } from '@classes/errors/network-error'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -202,7 +202,7 @@ export class CoreRatingSyncProvider extends CoreSyncBaseProvider<CoreRatingSyncI | |||||||
|             // Nothing to sync.
 |             // Nothing to sync.
 | ||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // Cannot sync in offline.
 |             // Cannot sync in offline.
 | ||||||
|             throw new CoreNetworkError(); |             throw new CoreNetworkError(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ import { ContextLevel } from '@/core/constants'; | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreSiteWSPreSets, CoreSite } from '@classes/site'; | import { CoreSiteWSPreSets, CoreSite } from '@classes/site'; | ||||||
| import { CoreUser } from '@features/user/services/user'; | import { CoreUser } from '@features/user/services/user'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreWSExternalWarning } from '@services/ws'; | import { CoreWSExternalWarning } from '@services/ws'; | ||||||
| @ -114,7 +114,7 @@ export class CoreRatingProvider { | |||||||
|             }, siteId); |             }, siteId); | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!CoreApp.isOnline()) { |         if (!CoreNetwork.isOnline()) { | ||||||
|             // App is offline, store the action.
 |             // App is offline, store the action.
 | ||||||
|             return storeOffline(); |             return storeOffline(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -26,6 +26,8 @@ import { CorePushNotifications } from '@features/pushnotifications/services/push | |||||||
| import { CoreConfig } from '@services/config'; | import { CoreConfig } from '@services/config'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Device Info to be shown and copied to clipboard. |  * Device Info to be shown and copied to clipboard. | ||||||
| @ -91,8 +93,8 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy { | |||||||
|             versionCode: CoreConstants.CONFIG.versioncode, |             versionCode: CoreConstants.CONFIG.versioncode, | ||||||
|             compilationTime: CoreConstants.BUILD.compilationTime || 0, |             compilationTime: CoreConstants.BUILD.compilationTime || 0, | ||||||
|             lastCommit: CoreConstants.BUILD.lastCommitHash || '', |             lastCommit: CoreConstants.BUILD.lastCommitHash || '', | ||||||
|             networkStatus: appProvider.isOnline() ? 'online' : 'offline', |             networkStatus: CoreNetwork.isOnline() ? 'online' : 'offline', | ||||||
|             wifiConnection: appProvider.isWifi() ? 'yes' : 'no', |             wifiConnection: CoreNetwork.isWifi() ? 'yes' : 'no', | ||||||
|             localNotifAvailable: CoreLocalNotifications.isAvailable() ? 'yes' : 'no', |             localNotifAvailable: CoreLocalNotifications.isAvailable() ? 'yes' : 'no', | ||||||
|             pushId: CorePushNotifications.getPushId(), |             pushId: CorePushNotifications.getPushId(), | ||||||
|             deviceType: '', |             deviceType: '', | ||||||
| @ -108,7 +110,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy { | |||||||
|                 ' (' + window.screen.width + 'x' + window.screen.height + ')'; |                 ' (' + window.screen.width + 'x' + window.screen.height + ')'; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (appProvider.isMobile()) { |         if (CorePlatform.isMobile()) { | ||||||
|             this.deviceInfo.deviceType = Platform.is('tablet') ? 'tablet' : 'phone'; |             this.deviceInfo.deviceType = Platform.is('tablet') ? 'tablet' : 'phone'; | ||||||
|             if (appProvider.isAndroid()) { |             if (appProvider.isAndroid()) { | ||||||
|                 this.deviceInfo.deviceOs = 'android'; |                 this.deviceInfo.deviceOs = 'android'; | ||||||
| @ -178,7 +180,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy { | |||||||
|         this.onlineObserver = Network.onChange().subscribe(() => { |         this.onlineObserver = Network.onChange().subscribe(() => { | ||||||
|             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 |             // Execute the callback in the Angular zone, so change detection doesn't stop working.
 | ||||||
|             NgZone.run(() => { |             NgZone.run(() => { | ||||||
|                 this.deviceInfo.networkStatus = appProvider.isOnline() ? 'online' : 'offline'; |                 this.deviceInfo.networkStatus = CoreNetwork.isOnline() ? 'online' : 'offline'; | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -14,6 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
|  | import { CoreNetwork } from '@services/network'; | ||||||
| import { CoreCronDelegate } from '@services/cron'; | import { CoreCronDelegate } from '@services/cron'; | ||||||
| import { CoreEvents } from '@singletons/events'; | import { CoreEvents } from '@singletons/events'; | ||||||
| import { CoreFilepool } from '@services/filepool'; | import { CoreFilepool } from '@services/filepool'; | ||||||
| @ -262,10 +263,10 @@ export class CoreSettingsHelperProvider { | |||||||
|         if (site.isLoggedOut()) { |         if (site.isLoggedOut()) { | ||||||
|             // Cannot sync logged out sites.
 |             // Cannot sync logged out sites.
 | ||||||
|             throw new CoreError(Translate.instant('core.settings.cannotsyncloggedout')); |             throw new CoreError(Translate.instant('core.settings.cannotsyncloggedout')); | ||||||
|         } else if (hasSyncHandlers && !CoreApp.isOnline()) { |         } else if (hasSyncHandlers && !CoreNetwork.isOnline()) { | ||||||
|             // We need connection to execute sync.
 |             // We need connection to execute sync.
 | ||||||
|             throw new CoreError(Translate.instant('core.settings.cannotsyncoffline')); |             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')); |             throw new CoreError(Translate.instant('core.settings.cannotsyncwithoutwifi')); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -30,6 +30,7 @@ import { CoreEvents } from '@singletons/events'; | |||||||
| import { CoreLogger } from '@singletons/logger'; | import { CoreLogger } from '@singletons/logger'; | ||||||
| import { CoreSitePluginsModuleHandler } from '../classes/handlers/module-handler'; | import { CoreSitePluginsModuleHandler } from '../classes/handlers/module-handler'; | ||||||
| import { CorePromisedValue } from '@classes/promised-value'; | import { CorePromisedValue } from '@classes/promised-value'; | ||||||
|  | import { CorePlatform } from '@services/platform'; | ||||||
| 
 | 
 | ||||||
| const ROOT_CACHE_KEY = 'CoreSitePlugins:'; | const ROOT_CACHE_KEY = 'CoreSitePlugins:'; | ||||||
| 
 | 
 | ||||||
| @ -90,7 +91,7 @@ export class CoreSitePluginsProvider { | |||||||
|             applang: lang, |             applang: lang, | ||||||
|             appcustomurlscheme: CoreConstants.CONFIG.customurlscheme, |             appcustomurlscheme: CoreConstants.CONFIG.customurlscheme, | ||||||
|             appisdesktop: false, |             appisdesktop: false, | ||||||
|             appismobile: CoreApp.isMobile(), |             appismobile: CorePlatform.isMobile(), | ||||||
|             appiswide: CoreApp.isWide(), |             appiswide: CoreApp.isWide(), | ||||||
|             appplatform: 'browser', |             appplatform: 'browser', | ||||||
|         }; |         }; | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ import { CoreDomUtils } from '@services/utils/dom'; | |||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreEventObserver, CoreEvents } from '@singletons/events'; | 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 { CoreUserHelper } from '@features/user/services/user-helper'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreIonLoadingElement } from '@classes/ion-loading'; | import { CoreIonLoadingElement } from '@classes/ion-loading'; | ||||||
| @ -65,7 +65,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         this.obsProfileRefreshed = CoreEvents.on(CoreUserProvider.PROFILE_REFRESHED, (data) => { |         this.obsProfileRefreshed = CoreEvents.on(USER_PROFILE_REFRESHED, (data) => { | ||||||
|             if (!this.user || !data.user) { |             if (!this.user || !data.user) { | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| @ -147,7 +147,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy { | |||||||
|             await CoreSites.updateSiteInfo(this.site.getId()); |             await CoreSites.updateSiteInfo(this.site.getId()); | ||||||
|         } catch { |         } catch { | ||||||
|             // Cannot update site info. Assume the profile image is the right one.
 |             // 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, |                 userId: this.userId, | ||||||
|                 picture: this.user.profileimageurl, |                 picture: this.user.profileimageurl, | ||||||
|             }, this.site.getId()); |             }, this.site.getId()); | ||||||
| @ -158,7 +158,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy { | |||||||
|             await this.refreshUser(); |             await this.refreshUser(); | ||||||
|         } else { |         } else { | ||||||
|             // Now they're the same, send event to use the right avatar in the rest of the app.
 |             // 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, |                 userId: this.userId, | ||||||
|                 picture: this.user.profileimageurl, |                 picture: this.user.profileimageurl, | ||||||
|             }, this.site.getId()); |             }, 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()); |             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, |                 userId: this.userId, | ||||||
|                 picture: profileImageURL, |                 picture: profileImageURL, | ||||||
|             }, this.site.getId()); |             }, this.site.getId()); | ||||||
| @ -210,7 +210,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy { | |||||||
|         event?.complete(); |         event?.complete(); | ||||||
| 
 | 
 | ||||||
|         if (this.user) { |         if (this.user) { | ||||||
|             CoreEvents.trigger(CoreUserProvider.PROFILE_REFRESHED, { |             CoreEvents.trigger(USER_PROFILE_REFRESHED, { | ||||||
|                 courseId: this.courseId, |                 courseId: this.courseId, | ||||||
|                 userId: this.userId, |                 userId: this.userId, | ||||||
|                 user: this.user, |                 user: this.user, | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ import { CoreSite } from '@classes/site'; | |||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreEventObserver, CoreEvents } from '@singletons/events'; | 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 { CoreUserHelper } from '@features/user/services/user-helper'; | ||||||
| import { | import { | ||||||
|     CoreUserDelegate, |     CoreUserDelegate, | ||||||
| @ -64,7 +64,7 @@ export class CoreUserProfilePage implements OnInit, OnDestroy { | |||||||
|     users?: CoreUserSwipeItemsManager; |     users?: CoreUserSwipeItemsManager; | ||||||
| 
 | 
 | ||||||
|     constructor(private route: ActivatedRoute) { |     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) { |             if (!this.user || !data.user) { | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| @ -187,7 +187,7 @@ export class CoreUserProfilePage implements OnInit, OnDestroy { | |||||||
|         event?.complete(); |         event?.complete(); | ||||||
| 
 | 
 | ||||||
|         if (this.user) { |         if (this.user) { | ||||||
|             CoreEvents.trigger(CoreUserProvider.PROFILE_REFRESHED, { |             CoreEvents.trigger(USER_PROFILE_REFRESHED, { | ||||||
|                 courseId: this.courseId, |                 courseId: this.courseId, | ||||||
|                 userId: this.userId, |                 userId: this.userId, | ||||||
|                 user: this.user, |                 user: this.user, | ||||||
|  | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user