MOBILE-3321 core: Decouple Network from App
parent
a0a138f686
commit
73ee4df1ec
|
@ -41,7 +41,7 @@ import {
|
|||
import { AddonCalendarFilter, AddonCalendarHelper } from '../../services/calendar-helper';
|
||||
import { AddonCalendarOffline } from '../../services/calendar-offline';
|
||||
import { CoreCategoryData, CoreCourses } from '@features/courses/services/courses';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSwipeSlidesComponent } from '@components/swipe-slides/swipe-slides';
|
||||
import {
|
||||
CoreSwipeSlidesDynamicItem,
|
||||
|
@ -498,7 +498,7 @@ class AddonCalendarMonthSlidesItemsManagerSource extends CoreSwipeSlidesDynamicI
|
|||
// Don't pass courseId and categoryId, we'll filter them locally.
|
||||
result = await AddonCalendar.getMonthlyEvents(year, monthNumber);
|
||||
} catch (error) {
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Allow navigating to non-cached months in offline (behave as if using emergency cache).
|
||||
result = await AddonCalendarHelper.getOfflineMonthWeeks(year, monthNumber);
|
||||
} else {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
|
@ -183,7 +183,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
this.onlineObserver = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
|||
*/
|
||||
async fetchData(sync?: boolean): Promise<void> {
|
||||
this.syncIcon = CoreConstants.ICON_LOADING;
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
|
||||
if (sync) {
|
||||
await this.sync();
|
||||
|
@ -674,7 +674,7 @@ class AddonCalendarDaySlidesItemsManagerSource extends CoreSwipeSlidesDynamicIte
|
|||
);
|
||||
} catch (error) {
|
||||
// Allow navigating to non-cached days in offline (behave as if using emergency cache).
|
||||
if (CoreApp.isOnline()) {
|
||||
if (CoreNetwork.isOnline()) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
import { AddonCalendarEventReminder, AddonCalendarHelper } from '../../services/calendar-helper';
|
||||
import { AddonCalendarOffline } from '../../services/calendar-offline';
|
||||
import { AddonCalendarSync, AddonCalendarSyncEvents, AddonCalendarSyncProvider } from '../../services/calendar-sync';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
|
@ -126,7 +126,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
|
|||
this.onlineObserver = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -184,7 +184,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
async fetchEvent(sync = false, showErrors = false): Promise<void> {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
|
||||
if (sync) {
|
||||
const deleted = await this.syncEvents(showErrors);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
|
@ -156,7 +156,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
|||
this.onlineObserver = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
|||
async fetchData(sync?: boolean, showErrors?: boolean): Promise<void> {
|
||||
|
||||
this.syncIcon = CoreConstants.ICON_LOADING;
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
|
||||
if (sync) {
|
||||
// Try to synchronize offline events.
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreSyncBaseProvider, CoreSyncBlockedError } from '@classes/base-sync';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -134,7 +134,7 @@ export class AddonCalendarSyncProvider extends CoreSyncBaseProvider<AddonCalenda
|
|||
const eventIds: number[] = await CoreUtils.ignoreErrors(AddonCalendarOffline.getAllEventsIds(siteId), []);
|
||||
|
||||
if (eventIds.length > 0) {
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUrlUtils } from '@services/utils/url';
|
||||
|
@ -241,7 +241,7 @@ export class AddonCalendarProvider {
|
|||
const storeOffline = (): Promise<boolean> =>
|
||||
AddonCalendarOffline.markDeleted(eventId, name, deleteAll, siteId).then(() => false);
|
||||
|
||||
if (forceOffline || !CoreApp.isOnline()) {
|
||||
if (forceOffline || !CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -1074,7 +1074,7 @@ export class AddonCalendarProvider {
|
|||
});
|
||||
|
||||
// Store starting week day preference, we need it in offline to show months that are not in cache.
|
||||
if (CoreApp.isOnline()) {
|
||||
if (CoreNetwork.isOnline()) {
|
||||
CoreConfig.set(AddonCalendarProvider.STARTING_WEEK_DAY, response.daynames[0].dayno);
|
||||
}
|
||||
|
||||
|
@ -1707,7 +1707,7 @@ export class AddonCalendarProvider {
|
|||
return { sent: false, event };
|
||||
};
|
||||
|
||||
if (options.forceOffline || !CoreApp.isOnline()) {
|
||||
if (options.forceOffline || !CoreNetwork.isOnline()) {
|
||||
// App is offline, store the event.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import {
|
||||
AddonMessagesOfflineConversationMessagesDBRecord,
|
||||
|
@ -283,7 +283,7 @@ export class AddonMessagesOfflineProvider {
|
|||
conversationid: conversation.id,
|
||||
text: message,
|
||||
timecreated: Date.now(),
|
||||
deviceoffline: CoreApp.isOnline() ? 0 : 1,
|
||||
deviceoffline: CoreNetwork.isOnline() ? 0 : 1,
|
||||
conversation: JSON.stringify({
|
||||
name: conversation.name || '',
|
||||
subname: conversation.subname || '',
|
||||
|
@ -314,7 +314,7 @@ export class AddonMessagesOfflineProvider {
|
|||
useridfrom: site.getUserId(),
|
||||
smallmessage: message,
|
||||
timecreated: new Date().getTime(),
|
||||
deviceoffline: CoreApp.isOnline() ? 0 : 1,
|
||||
deviceoffline: CoreNetwork.isOnline() ? 0 : 1,
|
||||
};
|
||||
|
||||
await site.getDb().insertRecord(MESSAGES_TABLE, entry);
|
||||
|
|
|
@ -26,7 +26,7 @@ import { CoreEvents } from '@singletons/events';
|
|||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
import { CoreUser } from '@features/user/services/user';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
|
@ -193,7 +193,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
|||
if (!messages.length) {
|
||||
// Nothing to sync.
|
||||
return result;
|
||||
} else if (!CoreApp.isOnline()) {
|
||||
} else if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline. Mark messages as device offline.
|
||||
AddonMessagesOffline.setMessagesDeviceOffline(messages, true);
|
||||
|
||||
|
@ -228,7 +228,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
|||
} catch (error) {
|
||||
if (!CoreUtils.isWebServiceError(error)) {
|
||||
// Error sending, stop execution.
|
||||
if (CoreApp.isOnline()) {
|
||||
if (CoreNetwork.isOnline()) {
|
||||
// App is online, unmark deviceoffline if marked.
|
||||
AddonMessagesOffline.setMessagesDeviceOffline(messages, false);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreLogger } from '@singletons/logger';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreUser, CoreUserBasicData } from '@features/user/services/user';
|
||||
import {
|
||||
AddonMessagesOffline,
|
||||
|
@ -2424,7 +2424,7 @@ export class AddonMessagesProvider {
|
|||
|
||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the message.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -2555,7 +2555,7 @@ export class AddonMessagesProvider {
|
|||
};
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the message.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ import { AddonModAssignOffline } from '../../services/assign-offline';
|
|||
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper';
|
||||
import { CoreLang } from '@services/lang';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
|
@ -292,7 +292,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
|
||||
|
||||
return;
|
||||
|
|
|
@ -35,7 +35,7 @@ import {
|
|||
import { CoreSync } from '@services/sync';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||
import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper';
|
||||
import { AddonModAssignSubmissionDelegate } from './submission-delegate';
|
||||
|
@ -215,7 +215,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
|
|||
return result;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import { CoreGrades } from '@features/grades/services/grades';
|
|||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { AddonModAssignOffline } from './assign-offline';
|
||||
import { AddonModAssignSubmissionDelegate } from './submission-delegate';
|
||||
|
@ -1027,7 +1027,7 @@ export class AddonModAssignProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (allowOffline && !CoreApp.isOnline()) {
|
||||
if (allowOffline && !CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -1137,7 +1137,7 @@ export class AddonModAssignProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (forceOffline || !CoreApp.isOnline()) {
|
||||
if (forceOffline || !CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -1234,7 +1234,7 @@ export class AddonModAssignProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
|||
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
||||
import { CoreTag, CoreTagItem } from '@features/tag/services/tag';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
|
@ -190,7 +190,7 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy {
|
|||
|
||||
if (!module.contents?.length || (refresh && !contentsAlreadyLoaded)) {
|
||||
// Try to load the contents.
|
||||
const ignoreCache = refresh && CoreApp.isOnline();
|
||||
const ignoreCache = refresh && CoreNetwork.isOnline();
|
||||
|
||||
try {
|
||||
await CoreCourse.loadModuleContents(module, undefined, undefined, false, ignoreCache);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { ModalController, Network, NgZone } from '@singletons';
|
||||
|
@ -40,12 +40,12 @@ export class AddonModChatUsersModalComponent implements OnInit, OnDestroy {
|
|||
protected onlineSubscription: Subscription;
|
||||
|
||||
constructor() {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
this.currentUserId = CoreSites.getCurrentSiteUserId();
|
||||
this.onlineSubscription = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import { CoreSendMessageFormComponent } from '@components/send-message-form/send
|
|||
import { CanLeave } from '@guards/can-leave';
|
||||
import { IonContent } from '@ionic/angular';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
|
@ -65,11 +66,11 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave {
|
|||
|
||||
constructor() {
|
||||
this.currentUserId = CoreSites.getCurrentSiteUserId();
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
this.onlineSubscription = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
|
|||
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
@ -160,7 +160,7 @@ export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvid
|
|||
return result;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreWSError } from '@classes/errors/wserror';
|
|||
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
||||
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -90,7 +90,7 @@ export class AddonModChoiceProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ export class AddonModChoiceProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
|||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreRatingSync } from '@features/rating/services/rating-sync';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFileEntry } from '@services/file-helper';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
|
@ -184,7 +184,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
|
|||
return result;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
|||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreRatingInfo } from '@features/rating/services/rating';
|
||||
import { CoreTagItem } from '@features/tag/services/tag';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFileEntry } from '@services/file-helper';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||
|
@ -136,7 +136,7 @@ export class AddonModDataProvider {
|
|||
};
|
||||
|
||||
// Checks to store offline.
|
||||
if (!CoreApp.isOnline() || forceOffline) {
|
||||
if (!CoreNetwork.isOnline() || forceOffline) {
|
||||
const notifications = this.checkFields(fields, contents);
|
||||
if (notifications.length > 0) {
|
||||
return { fieldnotifications: notifications };
|
||||
|
@ -147,7 +147,7 @@ export class AddonModDataProvider {
|
|||
await this.deleteEntryOfflineAction(dataId, entryId, AddonModDataAction.ADD, siteId);
|
||||
|
||||
// App is offline, store the action.
|
||||
if (!CoreApp.isOnline() || forceOffline) {
|
||||
if (!CoreNetwork.isOnline() || forceOffline) {
|
||||
return storeOffline();
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ export class AddonModDataProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ export class AddonModDataProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ export class AddonModDataProvider {
|
|||
};
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline() || forceOffline) {
|
||||
if (!CoreNetwork.isOnline() || forceOffline) {
|
||||
const notifications = this.checkFields(fields, contents);
|
||||
if (notifications.length > 0) {
|
||||
return { fieldnotifications: notifications };
|
||||
|
@ -446,7 +446,7 @@ export class AddonModDataProvider {
|
|||
// Remove unnecessary not synced actions.
|
||||
await this.deleteEntryOfflineAction(dataId, entryId, AddonModDataAction.EDIT, siteId);
|
||||
|
||||
if (!CoreApp.isOnline() || forceOffline) {
|
||||
if (!CoreNetwork.isOnline() || forceOffline) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreCourse, CoreCourseCommonModWSOptions } from '@features/course/servi
|
|||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CanLeave } from '@guards/can-leave';
|
||||
import { IonContent } from '@ionic/angular';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
|
@ -83,7 +83,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
|||
this.onlineObserver = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.offline = !CoreApp.isOnline();
|
||||
this.offline = !CoreNetwork.isOnline();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
|||
try {
|
||||
this.module = await CoreCourse.getModule(this.cmId, this.courseId, undefined, true, false, this.currentSite.getId());
|
||||
|
||||
this.offline = !CoreApp.isOnline();
|
||||
this.offline = !CoreNetwork.isOnline();
|
||||
const options = {
|
||||
cmId: this.cmId,
|
||||
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
|
|||
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
|
||||
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -174,7 +174,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
|
|||
return result;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import { CoreError } from '@classes/errors/error';
|
|||
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
||||
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -1187,7 +1187,7 @@ export class AddonModFeedbackProvider {
|
|||
return response;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { AddonModForum, AddonModForumPost } from '@addons/mod/forum/services/forum';
|
||||
import { PopoverController } from '@singletons';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
|
@ -101,7 +101,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit {
|
|||
*/
|
||||
deletePost(): void {
|
||||
if (!this.offlinePost) {
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
CoreDomUtils.showErrorModal(new CoreNetworkError());
|
||||
|
||||
return;
|
||||
|
@ -117,7 +117,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit {
|
|||
* Edit a post.
|
||||
*/
|
||||
editPost(): void {
|
||||
if (!this.offlinePost && !CoreApp.isOnline()) {
|
||||
if (!this.offlinePost && !CoreNetwork.isOnline()) {
|
||||
CoreDomUtils.showErrorModal(new CoreNetworkError());
|
||||
|
||||
return;
|
||||
|
|
|
@ -24,7 +24,7 @@ import { CoreRatingSyncProvider } from '@features/rating/services/rating-sync';
|
|||
import { CoreUser } from '@features/user/services/user';
|
||||
import { CanLeave } from '@guards/can-leave';
|
||||
import { IonContent, IonRefresher } from '@ionic/angular';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreScreen } from '@services/screen';
|
||||
import { CoreSites } from '@services/sites';
|
||||
|
@ -164,12 +164,12 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
return;
|
||||
}
|
||||
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
this.externalUrl = CoreSites.getCurrentSite()?.createSiteUrl('/mod/forum/discuss.php', { d: this.discussionId.toString() });
|
||||
this.onlineObserver = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { FileEntry } from '@ionic-native/file/ngx';
|
||||
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreUser } from '@features/user/services/user';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
|
@ -124,7 +124,7 @@ export class AddonModForumHelperProvider {
|
|||
await AddonModForumOffline.deleteNewDiscussion(forumId, timeCreated, siteId);
|
||||
}
|
||||
|
||||
if (saveOffline || !CoreApp.isOnline()) {
|
||||
if (saveOffline || !CoreNetwork.isOnline()) {
|
||||
await storeOffline();
|
||||
|
||||
return null;
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/act
|
|||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreRatingSync } from '@features/rating/services/rating-sync';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreGroups } from '@services/groups';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
|
@ -230,7 +230,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
[] as AddonModForumOfflineDiscussion[],
|
||||
);
|
||||
|
||||
if (discussions.length !== 0 && !CoreApp.isOnline()) {
|
||||
if (discussions.length !== 0 && !CoreNetwork.isOnline()) {
|
||||
throw new Error('cannot sync in offline');
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
if (!replies.length) {
|
||||
// Nothing to sync.
|
||||
return { warnings: [], updated: false };
|
||||
} else if (!CoreApp.isOnline()) {
|
||||
} else if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
return Promise.reject(null);
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
|
|||
[] as AddonModForumOfflineReply[],
|
||||
);
|
||||
|
||||
if (replies.length !== 0 && !CoreApp.isOnline()) {
|
||||
if (replies.length !== 0 && !CoreNetwork.isOnline()) {
|
||||
throw new Error('Cannot sync in offline');
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
|||
import { CoreRatingInfo } from '@features/rating/services/rating';
|
||||
import { CoreTagItem } from '@features/tag/services/tag';
|
||||
import { CoreUser } from '@features/user/services/user';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFileEntry } from '@services/file-helper';
|
||||
import { CoreGroups } from '@services/groups';
|
||||
import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
|
@ -756,7 +756,7 @@ export class AddonModForumProvider {
|
|||
} catch (error) {
|
||||
// Try to get the data from cache stored with the old WS method.
|
||||
if (
|
||||
CoreApp.isOnline() ||
|
||||
CoreNetwork.isOnline() ||
|
||||
method !== 'mod_forum_get_forum_discussions' ||
|
||||
options.sortOrder !== AddonModForumProvider.SORTORDER_LASTPOST_DESC
|
||||
) {
|
||||
|
@ -1065,7 +1065,7 @@ export class AddonModForumProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline() && allowOffline) {
|
||||
if (!CoreNetwork.isOnline() && allowOffline) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
|
|||
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreRatingSync } from '@features/rating/services/rating-sync';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -189,7 +189,7 @@ export class AddonModGlossarySyncProvider extends CoreCourseActivitySyncBaseProv
|
|||
await CoreUtils.ignoreErrors(this.setSyncTime(syncId, siteId));
|
||||
|
||||
return result;
|
||||
} else if (!CoreApp.isOnline()) {
|
||||
} else if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
|||
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreRatingInfo } from '@features/rating/services/rating';
|
||||
import { CoreTagItem } from '@features/tag/services/tag';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||
|
@ -898,7 +898,7 @@ export class AddonModGlossaryProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline() && otherOptions.allowOffline) {
|
||||
if (!CoreNetwork.isOnline() && otherOptions.allowOffline) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import { CoreH5PHelper } from '@features/h5p/classes/helper';
|
|||
import { CoreH5P } from '@features/h5p/services/h5p';
|
||||
import { CoreXAPIOffline } from '@features/xapi/services/offline';
|
||||
import { CoreXAPI } from '@features/xapi/services/xapi';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
|
@ -149,7 +149,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
|
|||
// Cannot download the file or already downloaded, play the package directly.
|
||||
this.play();
|
||||
|
||||
} else if ((this.state == CoreConstants.NOT_DOWNLOADED || this.state == CoreConstants.OUTDATED) && CoreApp.isOnline() &&
|
||||
} else if ((this.state == CoreConstants.NOT_DOWNLOADED || this.state == CoreConstants.OUTDATED) && CoreNetwork.isOnline() &&
|
||||
this.deployedFile?.filesize && CoreFilepool.shouldDownload(this.deployedFile.filesize)) {
|
||||
// Package is small, download it automatically. Don't block this function for this.
|
||||
this.downloadAutomatically();
|
||||
|
@ -280,7 +280,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
|
||||
|
||||
return;
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/act
|
|||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreXAPIOffline } from '@features/xapi/services/offline';
|
||||
import { CoreXAPI } from '@features/xapi/services/xapi';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
@ -103,7 +103,7 @@ export class AddonModH5PActivitySyncProvider extends CoreCourseActivitySyncBaseP
|
|||
syncActivity(contextId: number, siteId?: string): Promise<AddonModH5PActivitySyncResult> {
|
||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreCourse } from '@features/course/services/course';
|
|||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
|
@ -189,7 +189,7 @@ export class AddonModImscpViewPage implements OnInit {
|
|||
|
||||
if (!module.contents?.length || (refresh && !contentsAlreadyLoaded)) {
|
||||
// Try to load the contents.
|
||||
const ignoreCache = refresh && CoreApp.isOnline();
|
||||
const ignoreCache = refresh && CoreNetwork.isOnline();
|
||||
|
||||
try {
|
||||
await CoreCourse.loadModuleContents(module, undefined, undefined, false, ignoreCache);
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
|||
import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSitesCommonWSOptions, CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
|
@ -181,7 +181,7 @@ export class AddonModImscpProvider {
|
|||
return CoreText.concatenatePaths(dirPath, itemHref);
|
||||
} catch (error) {
|
||||
// Error getting directory, there was an error downloading or we're in browser. Return online URL if connected.
|
||||
if (CoreApp.isOnline()) {
|
||||
if (CoreNetwork.isOnline()) {
|
||||
const contents = await CoreCourse.getModuleContents(module);
|
||||
|
||||
const indexUrl = this.getFileUrlFromContents(contents, itemHref);
|
||||
|
|
|
@ -18,7 +18,7 @@ import { IonContent } from '@ionic/angular';
|
|||
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { CanLeave } from '@guards/can-leave';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
|
@ -280,7 +280,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
|
|||
// If lesson has offline data already, use offline mode.
|
||||
this.offline = await AddonModLessonOffline.hasOfflineData(this.lesson.id);
|
||||
|
||||
if (!this.offline && !CoreApp.isOnline() && AddonModLesson.isLessonOffline(this.lesson) && !this.review) {
|
||||
if (!this.offline && !CoreNetwork.isOnline() && AddonModLesson.isLessonOffline(this.lesson) && !this.review) {
|
||||
// Lesson doesn't have offline data, but it allows offline and the device is offline. Use offline mode.
|
||||
this.offline = true;
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
|
|||
protected async finishRetake(outOfTime?: boolean): Promise<void> {
|
||||
this.messages = [];
|
||||
|
||||
if (this.offline && CoreApp.isOnline()) {
|
||||
if (this.offline && CoreNetwork.isOnline()) {
|
||||
// Offline mode but the app is online. Try to sync the data.
|
||||
const result = await CoreUtils.ignoreErrors(
|
||||
AddonModLessonSync.syncLesson(this.lesson!.id, true, true),
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
|
|||
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
|
@ -275,7 +275,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid
|
|||
|
||||
if (!attempts.length) {
|
||||
return;
|
||||
} else if (!CoreApp.isOnline()) {
|
||||
} else if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ export class AddonModLessonSyncProvider extends CoreCourseActivitySyncBaseProvid
|
|||
await AddonModLessonOffline.deleteRetake(lessonId, siteId);
|
||||
|
||||
return;
|
||||
} else if (!CoreApp.isOnline()) {
|
||||
} else if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
|||
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
||||
import { CoreQuestion, CoreQuestionQuestionParsed } from '@features/question/services/question';
|
||||
import { CoreQuestionDelegate } from '@features/question/services/question-delegate';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -311,7 +311,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider
|
|||
return this.finishSync(siteId, quiz, courseId, warnings);
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreError(Translate.instant('core.cannotconnect'));
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents
|
|||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
|
@ -79,13 +80,13 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
|
|||
super.ngOnInit();
|
||||
|
||||
this.isIOS = CoreApp.isIOS();
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
|
||||
// Refresh online status when changes.
|
||||
this.onlineObserver = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
|
@ -80,7 +80,7 @@ export class AddonModResourceHelperProvider {
|
|||
return CoreText.concatenatePaths(dirPath, mainFilePath);
|
||||
} catch (e) {
|
||||
// Error getting directory, there was an error downloading or we're in browser. Return online URL.
|
||||
if (CoreApp.isOnline() && mainFile.fileurl) {
|
||||
if (CoreNetwork.isOnline() && mainFile.fileurl) {
|
||||
// This URL is going to be injected in an iframe, we need this to make it work.
|
||||
return CoreSites.getRequiredCurrentSite().checkAndFixPluginfileURL(mainFile.fileurl);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
|
|||
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
@ -168,7 +168,7 @@ export class AddonModSurveySyncProvider extends CoreCourseActivitySyncBaseProvid
|
|||
}
|
||||
|
||||
if (answersNumber > 0 && data) {
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import { CoreError } from '@classes/errors/error';
|
|||
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
||||
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -257,7 +257,7 @@ export class AddonModSurveyProvider {
|
|||
|
||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the message.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreCourse } from '@features/course/services/course';
|
|||
import { CoreTag, CoreTagItem } from '@features/tag/services/tag';
|
||||
import { CoreUser } from '@features/user/services/user';
|
||||
import { IonContent } from '@ionic/angular';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreGroup, CoreGroups } from '@services/groups';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
|
@ -116,13 +116,13 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
) {
|
||||
super('AddonModLessonIndexComponent', content, courseContentsPage);
|
||||
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
|
||||
// Refresh online status when changes.
|
||||
this.onlineSubscription = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreSyncBaseProvider, CoreSyncBlockedError } from '@classes/base-sync';
|
||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreGroups } from '@services/groups';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
|
@ -224,7 +224,7 @@ export class AddonModWikiSyncProvider extends CoreSyncBaseProvider<AddonModWikiS
|
|||
return result;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
|||
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreTagItem } from '@features/tag/services/tag';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -706,7 +706,7 @@ export class AddonModWikiProvider {
|
|||
return -1;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import { CoreSyncBaseProvider, CoreSyncBlockedError } from '@classes/base-sync';
|
|||
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFileEntry } from '@services/file-helper';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
|
@ -195,7 +195,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
|
|||
return result;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
|||
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreGradesMenuItem } from '@features/grades/services/grades-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreTextFormat, defaultTextFormat } from '@services/utils/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -729,7 +729,7 @@ export class AddonModWorkshopProvider {
|
|||
// If we are editing an offline submission, discard previous first.
|
||||
await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.ADD, siteId);
|
||||
|
||||
if (!CoreApp.isOnline() && allowOffline) {
|
||||
if (!CoreNetwork.isOnline() && allowOffline) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -825,7 +825,7 @@ export class AddonModWorkshopProvider {
|
|||
// If we are editing an offline discussion, discard previous first.
|
||||
await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.UPDATE, siteId);
|
||||
|
||||
if (!CoreApp.isOnline() && allowOffline) {
|
||||
if (!CoreNetwork.isOnline() && allowOffline) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -904,7 +904,7 @@ export class AddonModWorkshopProvider {
|
|||
// If we are editing an offline discussion, discard previous first.
|
||||
await AddonModWorkshopOffline.deleteSubmissionAction(workshopId, AddonModWorkshopAction.DELETE, siteId);
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -1173,7 +1173,7 @@ export class AddonModWorkshopProvider {
|
|||
|
||||
// If we are editing an offline discussion, discard previous first.
|
||||
await AddonModWorkshopOffline.deleteAssessment(workshopId, assessmentId, siteId);
|
||||
if (!CoreApp.isOnline() && allowOffline) {
|
||||
if (!CoreNetwork.isOnline() && allowOffline) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -1251,7 +1251,7 @@ export class AddonModWorkshopProvider {
|
|||
|
||||
// If we are editing an offline discussion, discard previous first.
|
||||
await AddonModWorkshopOffline.deleteEvaluateSubmission(workshopId, submissionId, siteId);
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -1342,7 +1342,7 @@ export class AddonModWorkshopProvider {
|
|||
|
||||
// If we are editing an offline discussion, discard previous first.
|
||||
await AddonModWorkshopOffline.deleteEvaluateAssessment(workshopId, assessmentId, siteId);
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreSyncBaseProvider } from '@classes/base-sync';
|
||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||
import { CoreCourses } from '@features/courses/services/courses';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate, makeSingleton } from '@singletons';
|
||||
|
@ -148,7 +148,7 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider<AddonNotesSyncR
|
|||
return result;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import { CoreWSError } from '@classes/errors/wserror';
|
|||
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
||||
import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications';
|
||||
import { CoreUser } from '@features/user/services/user';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSExternalWarning } from '@services/ws';
|
||||
|
@ -58,7 +58,7 @@ export class AddonNotesProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the note.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ export class AddonNotesProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the note.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
|
|||
import { IonRefresher } from '@ionic/angular';
|
||||
import { Md5 } from 'ts-md5/dist/md5';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
|
@ -154,7 +154,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy {
|
|||
* Upload a new file.
|
||||
*/
|
||||
async uploadFile(): Promise<void> {
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true);
|
||||
|
||||
return;
|
||||
|
|
|
@ -32,6 +32,7 @@ import { CoreConstants } from '@/core/constants';
|
|||
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreDom } from '@singletons/dom';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
|
||||
const MOODLE_VERSION_PREFIX = 'version-';
|
||||
const MOODLEAPP_VERSION_PREFIX = 'moodleapp-';
|
||||
|
@ -310,7 +311,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||
Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
const isOnline = CoreApp.isOnline();
|
||||
const isOnline = CoreNetwork.isOnline();
|
||||
const hadOfflineMessage = document.body.classList.contains('core-offline');
|
||||
|
||||
document.body.classList.toggle('core-offline', !isOnline);
|
||||
|
@ -327,7 +328,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||
});
|
||||
});
|
||||
|
||||
const isOnline = CoreApp.isOnline();
|
||||
const isOnline = CoreNetwork.isOnline();
|
||||
document.body.classList.toggle('core-offline', !isOnline);
|
||||
|
||||
// Set StatusBar properties.
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
|
@ -272,7 +272,7 @@ export class CoreSyncBaseProvider<T = void> {
|
|||
* @return Resolved with siteIds selected. Rejected if offline.
|
||||
*/
|
||||
async syncOnSites(syncFunctionLog: string, syncFunction: (siteId: string) => void, siteId?: string): Promise<void> {
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
const message = `Cannot sync '${syncFunctionLog}' because device is offline.`;
|
||||
this.logger.debug(message);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import { InAppBrowserObject, InAppBrowserOptions } from '@ionic-native/in-app-br
|
|||
import { Md5 } from 'ts-md5/dist/md5';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreDB } from '@services/db';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { CoreFile } from '@services/file';
|
||||
|
@ -537,7 +538,7 @@ export class CoreSite {
|
|||
const initialToken = this.token || '';
|
||||
data = data || {};
|
||||
|
||||
if (!CoreApp.isOnline() && this.offlineDisabled) {
|
||||
if (!CoreNetwork.isOnline() && this.offlineDisabled) {
|
||||
throw new CoreError(Translate.instant('core.errorofflinedisabled'));
|
||||
}
|
||||
|
||||
|
@ -995,7 +996,7 @@ export class CoreSite {
|
|||
const now = Date.now();
|
||||
let expirationTime: number | undefined;
|
||||
|
||||
preSets.omitExpires = preSets.omitExpires || preSets.forceOffline || !CoreApp.isOnline();
|
||||
preSets.omitExpires = preSets.omitExpires || preSets.forceOffline || !CoreNetwork.isOnline();
|
||||
|
||||
if (!preSets.omitExpires) {
|
||||
expirationTime = entry.expirationTime + this.getExpirationDelay(preSets.updateFrequency);
|
||||
|
@ -1987,7 +1988,7 @@ export class CoreSite {
|
|||
updateFrequency = updateFrequency || CoreSite.FREQUENCY_USUALLY;
|
||||
let expirationDelay = this.UPDATE_FREQUENCIES[updateFrequency] || this.UPDATE_FREQUENCIES[CoreSite.FREQUENCY_USUALLY];
|
||||
|
||||
if (CoreApp.isNetworkAccessLimited()) {
|
||||
if (CoreNetwork.isNetworkAccessLimited()) {
|
||||
// Not WiFi, increase the expiration delay a 50% to decrease the data usage in this case.
|
||||
expirationDelay *= 1.5;
|
||||
}
|
||||
|
@ -2011,7 +2012,7 @@ export class CoreSite {
|
|||
} else if (this.tokenPluginFileWorksPromise) {
|
||||
// Check ongoing, use the same promise.
|
||||
return this.tokenPluginFileWorksPromise;
|
||||
} else if (!CoreApp.isOnline()) {
|
||||
} else if (!CoreNetwork.isOnline()) {
|
||||
// Not online, cannot check it. Assume it's working, but don't save the result.
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreFileUploader, CoreFileUploaderTypeList } from '@features/fileupload
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper';
|
||||
import { CoreFileEntry } from '@services/file-helper';
|
||||
|
@ -132,7 +132,7 @@ export class CoreAttachmentsComponent implements OnInit {
|
|||
async add(): Promise<void> {
|
||||
const allowOffline = !!this.allowOffline && this.allowOffline !== 'false';
|
||||
|
||||
if (!allowOffline && !CoreApp.isOnline()) {
|
||||
if (!allowOffline && !CoreNetwork.isOnline()) {
|
||||
CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true);
|
||||
|
||||
return;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
import { Component, Input, Output, OnInit, OnDestroy, EventEmitter } from '@angular/core';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import { CorePluginFileDelegate } from '@services/plugin-file-delegate';
|
||||
|
@ -197,7 +198,7 @@ export class CoreFileComponent implements OnInit, OnDestroy {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline() && (!openAfterDownload || (openAfterDownload &&
|
||||
if (!CoreNetwork.isOnline() && (!openAfterDownload || (openAfterDownload &&
|
||||
!CoreFileHelper.isStateDownloaded(this.state)))) {
|
||||
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
|
||||
import { Component, Input, OnInit, OnChanges, OnDestroy, SimpleChange } from '@angular/core';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreUserProvider, CoreUserBasicData } from '@features/user/services/user';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
|
||||
/**
|
||||
* Component to display a "user avatar".
|
||||
|
@ -119,7 +119,7 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy {
|
|||
return this.user.lastaccess * 1000 >= time;
|
||||
} else {
|
||||
// You have to have Internet access first.
|
||||
return !!this.user.isonline && CoreApp.isOnline();
|
||||
return !!this.user.isonline && CoreNetwork.isOnline();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import { CoreError } from '@classes/errors/error';
|
|||
import { CoreSite } from '@classes/site';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreConstants } from '../constants';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
|
||||
/**
|
||||
* Directive to handle external content.
|
||||
|
@ -427,7 +428,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges, O
|
|||
clickableEl.addEventListener(eventName, () => {
|
||||
// User played media or opened a downloadable link.
|
||||
// Download the file if in wifi and it hasn't been downloaded already (for big files).
|
||||
if (state !== CoreConstants.DOWNLOADED && state !== CoreConstants.DOWNLOADING && CoreApp.isWifi()) {
|
||||
if (state !== CoreConstants.DOWNLOADED && state !== CoreConstants.DOWNLOADING && CoreNetwork.isWifi()) {
|
||||
// We aren't using the result, so it doesn't matter which of the 2 functions we call.
|
||||
CoreFilepool.getUrlByUrl(site.getId(), url, this.component, this.componentId, 0, false);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import { CoreCommentsOffline } from '@features/comments/services/comments-offlin
|
|||
import { CoreCommentsDBRecord } from '@features/comments/services/database/comments';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import moment from 'moment';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
|
@ -108,11 +109,11 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy {
|
|||
}
|
||||
}, CoreSites.getCurrentSiteId());
|
||||
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
this.onlineObserver = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreEvents } from '@singletons/events';
|
|||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { CoreCommentsOffline } from './comments-offline';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||
import { CoreCommentsDBRecord, CoreCommentsDeletedDBRecord } from './database/comments';
|
||||
|
@ -204,7 +204,7 @@ export class CoreCommentsSyncProvider extends CoreSyncBaseProvider<CoreCommentsS
|
|||
return result;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSExternalWarning } from '@services/ws';
|
||||
|
@ -95,7 +95,7 @@ export class CoreCommentsProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the comment.
|
||||
return storeOffline();
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ export class CoreCommentsProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the comment.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { CoreConstants } from '@/core/constants';
|
||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreCourse, CoreCourseAnyModuleData } from '../services/course';
|
||||
|
@ -84,7 +84,7 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
|
|||
): Promise<void> {
|
||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot prefetch in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { CoreConstants } from '@/core/constants';
|
|||
import { OnInit, OnDestroy, Input, Output, EventEmitter, Component, Optional, Inject } from '@angular/core';
|
||||
import { CoreAnyError } from '@classes/errors/error';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
|
||||
|
@ -354,7 +354,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
|
|||
|
||||
if (!this.module.contents?.length || (refresh && !contentsAlreadyLoaded)) {
|
||||
// Try to load the contents.
|
||||
const ignoreCache = refresh && CoreApp.isOnline();
|
||||
const ignoreCache = refresh && CoreNetwork.isOnline();
|
||||
|
||||
try {
|
||||
await CoreCourse.loadModuleContents(this.module, undefined, undefined, false, ignoreCache);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
|
@ -57,7 +57,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
|
|||
* @return Promise resolved when all content is downloaded.
|
||||
*/
|
||||
async downloadOrPrefetch(module: CoreCourseModuleData, courseId: number, prefetch?: boolean, dirPath?: string): Promise<void> {
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot download in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg
|
|||
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
|
||||
import { CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses';
|
||||
import { CoreGradesFormattedRow, CoreGradesFormattedTableRow, CoreGradesHelper } from '@features/grades/services/grades-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
|
@ -79,13 +79,13 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
|
|||
|
||||
constructor() {
|
||||
this.siteId = CoreSites.getCurrentSiteId();
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
|
||||
// Refresh online status when changes.
|
||||
this.onlineSubscription = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.isOnline = CoreNetwork.isOnline();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ import {
|
|||
} from './module-prefetch-delegate';
|
||||
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSite } from '@classes/site';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreUrlUtils } from '@services/utils/url';
|
||||
|
@ -798,7 +798,7 @@ export class CoreCourseHelperProvider {
|
|||
files?: CoreCourseModuleContentFile[],
|
||||
options: CoreUtilsOpenFileOptions = {},
|
||||
): Promise<void> {
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Not online, get the offline file. It will fail if not found.
|
||||
let path: string | undefined;
|
||||
try {
|
||||
|
@ -950,7 +950,7 @@ export class CoreCourseHelperProvider {
|
|||
): Promise<string> {
|
||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||
|
||||
const isOnline = CoreApp.isOnline();
|
||||
const isOnline = CoreNetwork.isOnline();
|
||||
const mainFile = files[0];
|
||||
const timemodified = mainFile.timemodified || 0;
|
||||
|
||||
|
@ -969,7 +969,7 @@ export class CoreCourseHelperProvider {
|
|||
}
|
||||
|
||||
// Start the download if in wifi, but return the URL right away so the file is opened.
|
||||
if (CoreApp.isWifi()) {
|
||||
if (CoreNetwork.isWifi()) {
|
||||
this.downloadModule(module, courseId, component, componentId, files, siteId);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Params } from '@angular/router';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { CoreLogger } from '@singletons/logger';
|
||||
import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
|
@ -554,7 +554,7 @@ export class CoreCourseProvider {
|
|||
return sections;
|
||||
} catch {
|
||||
// The module might still be cached by a request with different parameters.
|
||||
if (!ignoreCache && !CoreApp.isOnline()) {
|
||||
if (!ignoreCache && !CoreNetwork.isOnline()) {
|
||||
if (includeStealth) {
|
||||
// Older versions didn't include the includestealthmodules option.
|
||||
return doRequest(site, courseId, moduleId, modName, false, true);
|
||||
|
@ -1168,7 +1168,7 @@ export class CoreCourseProvider {
|
|||
CoreCourseOffline.markCompletedManually(cmId, completed, courseId, undefined, siteId);
|
||||
|
||||
// The offline function requires a courseId and it could be missing because it's a calculated field.
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
|
@ -134,7 +134,7 @@ export class CoreCourseLogHelperProvider {
|
|||
async log(ws: string, data: Record<string, unknown>, component: string, componentId: number, siteId?: string): Promise<void> {
|
||||
const site = await CoreSites.getSite(siteId);
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return this.storeOffline(ws, data, component, componentId, site.getId());
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreSyncBaseProvider } from '@classes/base-sync';
|
||||
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreCourseOffline } from './course-offline';
|
||||
|
@ -167,7 +167,7 @@ export class CoreCourseSyncProvider extends CoreSyncBaseProvider<CoreCourseSyncR
|
|||
return result;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import { FileEntry, IFile } from '@ionic-native/file/ngx';
|
|||
import { MediaFile } from '@ionic-native/media-capture/ngx';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFile, CoreFileProvider, CoreFileProgressEvent } from '@services/file';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||
|
@ -122,7 +123,7 @@ export class CoreFileUploaderHelperProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!allowOffline && !CoreApp.isOnline()) {
|
||||
if (!allowOffline && !CoreNetwork.isOnline()) {
|
||||
throw new CoreError(Translate.instant('core.fileuploader.errormustbeonlinetoupload'));
|
||||
}
|
||||
|
||||
|
@ -132,7 +133,7 @@ export class CoreFileUploaderHelperProvider {
|
|||
|
||||
if (size < 0) {
|
||||
return CoreDomUtils.showConfirm(Translate.instant('core.fileuploader.confirmuploadunknownsize'));
|
||||
} else if (size >= wifiThreshold || (CoreApp.isNetworkAccessLimited() && size >= limitedThreshold)) {
|
||||
} else if (size >= wifiThreshold || (CoreNetwork.isNetworkAccessLimited() && size >= limitedThreshold)) {
|
||||
const readableSize = CoreTextUtils.bytesToSize(size, 2);
|
||||
|
||||
return CoreDomUtils.showConfirm(
|
||||
|
@ -365,7 +366,7 @@ export class CoreFileUploaderHelperProvider {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!allowOffline && !CoreApp.isOnline()) {
|
||||
if (!allowOffline && !CoreNetwork.isOnline()) {
|
||||
// Not allowed, show error.
|
||||
CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true);
|
||||
|
||||
|
@ -796,7 +797,7 @@ export class CoreFileUploaderHelperProvider {
|
|||
return this.uploadFile(path, maxSize, checkSize, options, siteId);
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
return errorUploading(Translate.instant('core.fileuploader.errormustbeonlinetoupload'));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreFilterDelegate } from './filter-delegate';
|
||||
import {
|
||||
|
@ -299,7 +299,7 @@ export class CoreFilterHelperProvider {
|
|||
|
||||
const cachedData = this.moduleContextsCache[siteId][courseId][contextLevel];
|
||||
|
||||
if (!CoreApp.isOnline() || Date.now() <= cachedData.time + site.getExpirationDelay(CoreSite.FREQUENCY_RARELY)) {
|
||||
if (!CoreNetwork.isOnline() || Date.now() <= cachedData.time + site.getExpirationDelay(CoreSite.FREQUENCY_RARELY)) {
|
||||
// We can use cache, return the filters if found.
|
||||
return cachedData.contexts[contextLevel] && cachedData.contexts[contextLevel][instanceId];
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSite } from '@classes/site';
|
||||
import { CoreWSExternalWarning } from '@services/ws';
|
||||
|
@ -338,7 +338,7 @@ export class CoreFilterProvider {
|
|||
|
||||
// Check if we have the contexts in the memory cache.
|
||||
const siteContexts = this.contextsCache[site.getId()];
|
||||
const isOnline = CoreApp.isOnline();
|
||||
const isOnline = CoreNetwork.isOnline();
|
||||
const result: CoreFilterClassifiedFilters = {};
|
||||
let allFound = true;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Component, Input, ElementRef, OnInit, OnDestroy, OnChanges, SimpleChange } from '@angular/core';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
|
@ -111,7 +111,7 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy {
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
async download(): Promise<void> {
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
|
||||
|
||||
return;
|
||||
|
@ -144,7 +144,7 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy {
|
|||
*/
|
||||
protected async attemptDownloadInBg(): Promise<void> {
|
||||
if (!this.urlParams || !this.src || !this.siteCanDownload || !CoreH5P.canGetTrustedH5PFileInSite() ||
|
||||
!CoreApp.isOnline()) {
|
||||
!CoreNetwork.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import { Subscription } from 'rxjs';
|
|||
import { debounceTime } from 'rxjs/operators';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreLoginHelper } from '@features/login/services/login-helper';
|
||||
|
@ -244,7 +245,7 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
|
||||
|
||||
return;
|
||||
|
|
|
@ -16,6 +16,7 @@ import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/co
|
|||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -201,7 +202,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
|
||||
|
||||
return;
|
||||
|
|
|
@ -16,6 +16,7 @@ import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
|||
import { FormBuilder, FormGroup, ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreConfig } from '@services/config';
|
||||
import { CoreSites, CoreSiteCheckResponse, CoreLoginSiteInfo, CoreSitesDemoSiteData } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -242,7 +243,7 @@ export class CoreLoginSitePage implements OnInit {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
CoreDomUtils.showErrorModal('core.networkerrormsg', true);
|
||||
|
||||
return;
|
||||
|
|
|
@ -16,7 +16,7 @@ import { ContextLevel } from '@/core/constants';
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreSyncBaseProvider } from '@classes/base-sync';
|
||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -202,7 +202,7 @@ export class CoreRatingSyncProvider extends CoreSyncBaseProvider<CoreRatingSyncI
|
|||
// Nothing to sync.
|
||||
return result;
|
||||
}
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot sync in offline.
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { ContextLevel } from '@/core/constants';
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreSiteWSPreSets, CoreSite } from '@classes/site';
|
||||
import { CoreUser } from '@features/user/services/user';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSExternalWarning } from '@services/ws';
|
||||
|
@ -114,7 +114,7 @@ export class CoreRatingProvider {
|
|||
}, siteId);
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import { CoreConfig } from '@services/config';
|
|||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CorePlatform } from '@services/platform';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
|
||||
/**
|
||||
* Device Info to be shown and copied to clipboard.
|
||||
|
@ -92,8 +93,8 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
|
|||
versionCode: CoreConstants.CONFIG.versioncode,
|
||||
compilationTime: CoreConstants.BUILD.compilationTime || 0,
|
||||
lastCommit: CoreConstants.BUILD.lastCommitHash || '',
|
||||
networkStatus: appProvider.isOnline() ? 'online' : 'offline',
|
||||
wifiConnection: appProvider.isWifi() ? 'yes' : 'no',
|
||||
networkStatus: CoreNetwork.isOnline() ? 'online' : 'offline',
|
||||
wifiConnection: CoreNetwork.isWifi() ? 'yes' : 'no',
|
||||
localNotifAvailable: CoreLocalNotifications.isAvailable() ? 'yes' : 'no',
|
||||
pushId: CorePushNotifications.getPushId(),
|
||||
deviceType: '',
|
||||
|
@ -179,7 +180,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
|
|||
this.onlineObserver = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.deviceInfo.networkStatus = appProvider.isOnline() ? 'online' : 'offline';
|
||||
this.deviceInfo.networkStatus = CoreNetwork.isOnline() ? 'online' : 'offline';
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreCronDelegate } from '@services/cron';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
|
@ -262,10 +263,10 @@ export class CoreSettingsHelperProvider {
|
|||
if (site.isLoggedOut()) {
|
||||
// Cannot sync logged out sites.
|
||||
throw new CoreError(Translate.instant('core.settings.cannotsyncloggedout'));
|
||||
} else if (hasSyncHandlers && !CoreApp.isOnline()) {
|
||||
} else if (hasSyncHandlers && !CoreNetwork.isOnline()) {
|
||||
// We need connection to execute sync.
|
||||
throw new CoreError(Translate.instant('core.settings.cannotsyncoffline'));
|
||||
} else if (hasSyncHandlers && syncOnlyOnWifi && CoreApp.isNetworkAccessLimited()) {
|
||||
} else if (hasSyncHandlers && syncOnlyOnWifi && CoreNetwork.isNetworkAccessLimited()) {
|
||||
throw new CoreError(Translate.instant('core.settings.cannotsyncwithoutwifi'));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -401,7 +401,7 @@ export class CoreUserProvider {
|
|||
|
||||
const preference = await CoreUtils.ignoreErrors(CoreUserOffline.getPreference(name, siteId));
|
||||
|
||||
if (preference && !CoreApp.isOnline()) {
|
||||
if (preference && !CoreNetwork.isOnline()) {
|
||||
// Offline, return stored value.
|
||||
return preference.value;
|
||||
}
|
||||
|
@ -760,7 +760,7 @@ export class CoreUserProvider {
|
|||
async setUserPreference(name: string, value: string, siteId?: string): Promise<void> {
|
||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Offline, just update the preference.
|
||||
return CoreUserOffline.setPreference(name, value);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreSite } from '@classes/site';
|
||||
|
@ -94,7 +94,7 @@ export class CoreXAPIProvider {
|
|||
return false;
|
||||
};
|
||||
|
||||
if (!CoreApp.isOnline() || options.offline) {
|
||||
if (!CoreNetwork.isOnline() || options.offline) {
|
||||
// App is offline, store the action.
|
||||
return storeOffline();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreDB } from '@services/db';
|
|||
import { CoreEvents } from '@singletons/events';
|
||||
import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
import { makeSingleton, Keyboard, Network, StatusBar, Platform, Device } from '@singletons';
|
||||
import { makeSingleton, Keyboard, StatusBar, Platform, Device } from '@singletons';
|
||||
import { CoreLogger } from '@singletons/logger';
|
||||
import { CoreColors } from '@singletons/colors';
|
||||
import { DBNAME, SCHEMA_VERSIONS_TABLE_NAME, SCHEMA_VERSIONS_TABLE_SCHEMA, SchemaVersionsDBEntry } from '@services/database/app';
|
||||
|
@ -30,6 +30,7 @@ import { CoreDatabaseTable } from '@classes/database/database-table';
|
|||
import { CorePromisedValue } from '@classes/promised-value';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { CorePlatform } from '@services/platform';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
|
||||
/**
|
||||
* Factory to provide some global functionalities, like access to the global app database.
|
||||
|
@ -53,7 +54,6 @@ export class CoreAppProvider {
|
|||
protected isKeyboardShown = false;
|
||||
protected keyboardOpening = false;
|
||||
protected keyboardClosing = false;
|
||||
protected forceOffline = false;
|
||||
protected redirect?: CoreRedirectData;
|
||||
protected schemaVersionsTable = asyncInstance<CoreDatabaseTable<SchemaVersionsDBEntry, 'name'>>();
|
||||
|
||||
|
@ -329,54 +329,30 @@ export class CoreAppProvider {
|
|||
* Returns whether we are online.
|
||||
*
|
||||
* @return Whether the app is online.
|
||||
* @deprecated since 4.1.0. Use CoreNetwork instead.
|
||||
*/
|
||||
isOnline(): boolean {
|
||||
if (this.forceOffline) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.isMobile()) {
|
||||
return navigator.onLine;
|
||||
}
|
||||
|
||||
let online = Network.type !== null && Network.type != Network.Connection.NONE &&
|
||||
Network.type != Network.Connection.UNKNOWN;
|
||||
|
||||
// Double check we are not online because we cannot rely 100% in Cordova APIs.
|
||||
if (!online && navigator.onLine) {
|
||||
online = true;
|
||||
}
|
||||
|
||||
return online;
|
||||
return CoreNetwork.isOnline();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if device uses a limited connection.
|
||||
*
|
||||
* @return Whether the device uses a limited connection.
|
||||
* @deprecated since 4.1.0. Use CoreNetwork instead.
|
||||
*/
|
||||
isNetworkAccessLimited(): boolean {
|
||||
if (!this.isMobile()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const limited = [
|
||||
Network.Connection.CELL_2G,
|
||||
Network.Connection.CELL_3G,
|
||||
Network.Connection.CELL_4G,
|
||||
Network.Connection.CELL,
|
||||
];
|
||||
|
||||
return limited.indexOf(Network.type) > -1;
|
||||
return CoreNetwork.isNetworkAccessLimited();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if device uses a wifi connection.
|
||||
*
|
||||
* @return Whether the device uses a wifi connection.
|
||||
* @deprecated since 4.1.0. Use CoreNetwork instead.
|
||||
*/
|
||||
isWifi(): boolean {
|
||||
return this.isOnline() && !this.isNetworkAccessLimited();
|
||||
return CoreNetwork.isWifi();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -668,9 +644,10 @@ export class CoreAppProvider {
|
|||
* Set value of forceOffline flag. If true, the app will think the device is offline.
|
||||
*
|
||||
* @param value Value to set.
|
||||
* @deprecated since 4.1.0. Use CoreNetwork instead.
|
||||
*/
|
||||
setForceOffline(value: boolean): void {
|
||||
this.forceOffline = !!value;
|
||||
CoreNetwork.setForceOffline(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreConfig } from '@services/config';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
|
@ -89,7 +90,7 @@ export class CoreCronDelegateService {
|
|||
const usesNetwork = this.handlerUsesNetwork(name);
|
||||
const isSync = !force && this.isHandlerSync(name);
|
||||
|
||||
if (usesNetwork && !CoreApp.isOnline()) {
|
||||
if (usesNetwork && !CoreNetwork.isOnline()) {
|
||||
// Offline, stop executing.
|
||||
const message = `Cannot execute handler because device is offline: ${name}`;
|
||||
this.logger.debug(message);
|
||||
|
@ -102,7 +103,7 @@ export class CoreCronDelegateService {
|
|||
// Check network connection.
|
||||
const syncOnlyOnWifi = await CoreConfig.get(CoreConstants.SETTINGS_SYNC_ONLY_ON_WIFI, false);
|
||||
|
||||
if (syncOnlyOnWifi && !CoreApp.isWifi()) {
|
||||
if (syncOnlyOnWifi && !CoreNetwork.isWifi()) {
|
||||
// Cannot execute in this network connection, retry soon.
|
||||
const message = `Cannot execute handler because device is using limited connection: ${name}`;
|
||||
this.logger.debug(message);
|
||||
|
|
|
@ -16,6 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { FileEntry } from '@ionic-native/file/ngx';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites } from '@services/sites';
|
||||
|
@ -167,8 +168,8 @@ export class CoreFileHelperProvider {
|
|||
}
|
||||
|
||||
// The file system is available.
|
||||
const isWifi = CoreApp.isWifi();
|
||||
const isOnline = CoreApp.isOnline();
|
||||
const isWifi = CoreNetwork.isWifi();
|
||||
const isOnline = CoreNetwork.isOnline();
|
||||
|
||||
if (state == CoreConstants.DOWNLOADED) {
|
||||
// File is downloaded, get the local file URL.
|
||||
|
|
|
@ -16,6 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { Md5 } from 'ts-md5/dist/md5';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreEventPackageStatusChanged, CoreEvents } from '@singletons/events';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CorePluginFileDelegate } from '@services/plugin-file-delegate';
|
||||
|
@ -506,7 +507,7 @@ export class CoreFilepoolProvider {
|
|||
if (this.sizeCache[fileUrl] !== undefined) {
|
||||
size = this.sizeCache[fileUrl];
|
||||
} else {
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
// Cannot check size in offline, stop.
|
||||
throw new CoreError(Translate.instant('core.cannotconnect'));
|
||||
}
|
||||
|
@ -515,7 +516,7 @@ export class CoreFilepoolProvider {
|
|||
}
|
||||
|
||||
// Calculate the size of the file.
|
||||
const isWifi = CoreApp.isWifi();
|
||||
const isWifi = CoreNetwork.isWifi();
|
||||
const sizeUnknown = size <= 0;
|
||||
|
||||
if (!sizeUnknown) {
|
||||
|
@ -550,7 +551,7 @@ export class CoreFilepoolProvider {
|
|||
* is not accessible. Also, this will have no effect if the queue is already running.
|
||||
*/
|
||||
protected checkQueueProcessing(): void {
|
||||
if (!CoreFile.isAvailable() || !CoreApp.isOnline()) {
|
||||
if (!CoreFile.isAvailable() || !CoreNetwork.isOnline()) {
|
||||
this.queueState = CoreFilepoolProvider.QUEUE_PAUSED;
|
||||
|
||||
return;
|
||||
|
@ -1053,7 +1054,7 @@ export class CoreFilepoolProvider {
|
|||
|
||||
if (!fileObject ||
|
||||
this.isFileOutdated(fileObject, options.revision, options.timemodified) &&
|
||||
CoreApp.isOnline() &&
|
||||
CoreNetwork.isOnline() &&
|
||||
!ignoreStale
|
||||
) {
|
||||
throw new CoreError('Needs to be downloaded');
|
||||
|
@ -1597,7 +1598,7 @@ export class CoreFilepoolProvider {
|
|||
throw new CoreError('File not downloaded.');
|
||||
}
|
||||
|
||||
if (this.isFileOutdated(entry, revision, timemodified) && CoreApp.isOnline()) {
|
||||
if (this.isFileOutdated(entry, revision, timemodified) && CoreNetwork.isOnline()) {
|
||||
throw new CoreError('File is outdated');
|
||||
}
|
||||
} catch (error) {
|
||||
|
@ -2497,7 +2498,7 @@ export class CoreFilepoolProvider {
|
|||
if (this.queueState !== CoreFilepoolProvider.QUEUE_RUNNING) {
|
||||
// Silently ignore, the queue is on pause.
|
||||
throw CoreFilepoolProvider.ERR_QUEUE_ON_PAUSE;
|
||||
} else if (!CoreFile.isAvailable() || !CoreApp.isOnline()) {
|
||||
} else if (!CoreFile.isAvailable() || !CoreNetwork.isOnline()) {
|
||||
throw CoreFilepoolProvider.ERR_FS_OR_NETWORK_UNAVAILABLE;
|
||||
}
|
||||
|
||||
|
@ -2817,7 +2818,7 @@ export class CoreFilepoolProvider {
|
|||
*/
|
||||
shouldDownload(size: number): boolean {
|
||||
return size <= CoreFilepoolProvider.DOWNLOAD_THRESHOLD ||
|
||||
(CoreApp.isWifi() && size <= CoreFilepoolProvider.WIFI_DOWNLOAD_THRESHOLD);
|
||||
(CoreNetwork.isWifi() && size <= CoreFilepoolProvider.WIFI_DOWNLOAD_THRESHOLD);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
// (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 { Injectable } from '@angular/core';
|
||||
import { CorePlatform } from '@services/platform';
|
||||
import { makeSingleton, Network } from '@singletons';
|
||||
|
||||
/**
|
||||
* Service to manage network information.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreNetworkService {
|
||||
|
||||
protected forceOffline = false;
|
||||
|
||||
/**
|
||||
* Set value of forceOffline flag. If true, the app will think the device is offline.
|
||||
*
|
||||
* @param value Value to set.
|
||||
*/
|
||||
setForceOffline(value: boolean): void {
|
||||
this.forceOffline = !!value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether we are online.
|
||||
*
|
||||
* @return Whether the app is online.
|
||||
*/
|
||||
isOnline(): boolean {
|
||||
if (this.forceOffline) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CorePlatform.isMobile()) {
|
||||
return navigator.onLine;
|
||||
}
|
||||
|
||||
let online = Network.type !== null && Network.type != Network.Connection.NONE &&
|
||||
Network.type != Network.Connection.UNKNOWN;
|
||||
|
||||
// Double check we are not online because we cannot rely 100% in Cordova APIs.
|
||||
if (!online && navigator.onLine) {
|
||||
online = true;
|
||||
}
|
||||
|
||||
return online;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if device uses a limited connection.
|
||||
*
|
||||
* @return Whether the device uses a limited connection.
|
||||
*/
|
||||
isNetworkAccessLimited(): boolean {
|
||||
if (!CorePlatform.isMobile()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const limited = [
|
||||
Network.Connection.CELL_2G,
|
||||
Network.Connection.CELL_3G,
|
||||
Network.Connection.CELL_4G,
|
||||
Network.Connection.CELL,
|
||||
];
|
||||
|
||||
return limited.indexOf(Network.type) > -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if device uses a wifi connection.
|
||||
*
|
||||
* @return Whether the device uses a wifi connection.
|
||||
*/
|
||||
isWifi(): boolean {
|
||||
return this.isOnline() && !this.isNetworkAccessLimited();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const CoreNetwork = makeSingleton(CoreNetworkService);
|
|
@ -60,6 +60,7 @@ import { CoreDatabaseConfiguration, CoreDatabaseTable } from '@classes/database/
|
|||
import { CoreDatabaseCachingStrategy, CoreDatabaseTableProxy } from '@classes/database/database-table-proxy';
|
||||
import { asyncInstance, AsyncInstance } from '../utils/async-instance';
|
||||
import { CoreConfig } from './config';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
|
||||
export const CORE_SITE_SCHEMAS = new InjectionToken<CoreSiteSchema[]>('CORE_SITE_SCHEMAS');
|
||||
export const CORE_SITE_CURRENT_SITE_ID_CONFIG = 'current_site_id';
|
||||
|
@ -216,7 +217,7 @@ export class CoreSitesProvider {
|
|||
|
||||
if (!CoreUrlUtils.isHttpURL(siteUrl)) {
|
||||
throw new CoreError(Translate.instant('core.login.invalidsite'));
|
||||
} else if (!CoreApp.isOnline()) {
|
||||
} else if (!CoreNetwork.isOnline()) {
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
||||
|
@ -429,7 +430,7 @@ export class CoreSitesProvider {
|
|||
service?: string,
|
||||
retry?: boolean,
|
||||
): Promise<CoreSiteUserTokenResponse> {
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ import { filter } from 'rxjs/operators';
|
|||
import { Subscription } from 'rxjs';
|
||||
import { CoreComponentsRegistry } from '@singletons/components-registry';
|
||||
import { CoreDom } from '@singletons/dom';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
|
||||
/*
|
||||
* "Utils" service with helper functions for UI, DOM elements and HTML code.
|
||||
|
@ -170,7 +171,7 @@ export class CoreDomUtilsProvider {
|
|||
limitedThreshold = limitedThreshold === undefined ? CoreConstants.DOWNLOAD_THRESHOLD : limitedThreshold;
|
||||
|
||||
let wifiPrefix = '';
|
||||
if (CoreApp.isNetworkAccessLimited()) {
|
||||
if (CoreNetwork.isNetworkAccessLimited()) {
|
||||
wifiPrefix = Translate.instant('core.course.confirmlimiteddownload');
|
||||
}
|
||||
|
||||
|
@ -194,7 +195,7 @@ export class CoreDomUtilsProvider {
|
|||
),
|
||||
);
|
||||
} else if (alwaysConfirm || size.size >= wifiThreshold ||
|
||||
(CoreApp.isNetworkAccessLimited() && size.size >= limitedThreshold)) {
|
||||
(CoreNetwork.isNetworkAccessLimited() && size.size >= limitedThreshold)) {
|
||||
message = message || (size.size === 0 ? 'core.course.confirmdownloadzerosize' : 'core.course.confirmdownload');
|
||||
|
||||
return this.showConfirm(
|
||||
|
|
|
@ -17,6 +17,7 @@ import { WKUserScriptWindow } from 'cordova-plugin-wkuserscript';
|
|||
import { WKWebViewCookiesWindow } from 'cordova-plugin-wkwebview-cookies';
|
||||
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import { CoreSites } from '@services/sites';
|
||||
|
@ -65,7 +66,7 @@ export class CoreIframeUtilsProvider {
|
|||
checkOnlineFrameInOffline(element: CoreFrameElement, isSubframe?: boolean): boolean {
|
||||
const src = 'src' in element ? element.src : element.data;
|
||||
|
||||
if (src && src != 'about:blank' && !CoreUrlUtils.isLocalFileUrl(src) && !CoreApp.isOnline()) {
|
||||
if (src && src != 'about:blank' && !CoreUrlUtils.isLocalFileUrl(src) && !CoreNetwork.isOnline()) {
|
||||
if (element.classList.contains('core-iframe-offline-disabled')) {
|
||||
// Iframe already hidden, stop.
|
||||
return true;
|
||||
|
|
|
@ -22,7 +22,7 @@ import { Observable } from 'rxjs';
|
|||
import { timeout } from 'rxjs/operators';
|
||||
|
||||
import { CoreNativeToAngularHttpResponse } from '@classes/native-to-angular-http';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFile, CoreFileFormat } from '@services/file';
|
||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||
import { CoreTextErrorObject, CoreTextUtils } from '@services/utils/text';
|
||||
|
@ -96,7 +96,7 @@ export class CoreWSProvider {
|
|||
call<T = unknown>(method: string, data: Record<string, unknown>, preSets: CoreWSPreSets): Promise<T> {
|
||||
if (!preSets) {
|
||||
throw new CoreError(Translate.instant('core.unexpectederror'));
|
||||
} else if (!CoreApp.isOnline()) {
|
||||
} else if (!CoreNetwork.isOnline()) {
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ export class CoreWSProvider {
|
|||
): Promise<CoreWSDownloadedFileEntry> {
|
||||
this.logger.debug('Downloading file', url, path, addExtension);
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ export class CoreWSProvider {
|
|||
* @return Timeout in ms.
|
||||
*/
|
||||
getRequestTimeout(): number {
|
||||
return CoreApp.isNetworkAccessLimited() ? CoreConstants.WS_TIMEOUT : CoreConstants.WS_TIMEOUT_WIFI;
|
||||
return CoreNetwork.isNetworkAccessLimited() ? CoreConstants.WS_TIMEOUT : CoreConstants.WS_TIMEOUT_WIFI;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -421,7 +421,7 @@ export class CoreWSProvider {
|
|||
|
||||
if (preSets.siteUrl === undefined) {
|
||||
throw new CoreAjaxError(Translate.instant('core.unexpectederror'));
|
||||
} else if (!CoreApp.isOnline()) {
|
||||
} else if (!CoreNetwork.isOnline()) {
|
||||
throw new CoreAjaxError(Translate.instant('core.networkerrormsg'));
|
||||
}
|
||||
|
||||
|
@ -789,7 +789,7 @@ export class CoreWSProvider {
|
|||
syncCall<T = unknown>(method: string, data: any, preSets: CoreWSPreSets): T {
|
||||
if (!preSets) {
|
||||
throw new CoreError(Translate.instant('core.unexpectederror'));
|
||||
} else if (!CoreApp.isOnline()) {
|
||||
} else if (!CoreNetwork.isOnline()) {
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
||||
|
@ -873,7 +873,7 @@ export class CoreWSProvider {
|
|||
throw new CoreError('Invalid options passed to upload file.');
|
||||
}
|
||||
|
||||
if (!CoreApp.isOnline()) {
|
||||
if (!CoreNetwork.isOnline()) {
|
||||
throw new CoreNetworkError();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue