MOBILE-2431: Wrap Ionic Native callbacks with NgZone.run
parent
cb18fd9112
commit
0020880c6a
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule, NgZone } from '@angular/core';
|
||||||
import { Network } from '@ionic-native/network';
|
import { Network } from '@ionic-native/network';
|
||||||
import { AddonMessagesProvider } from './providers/messages';
|
import { AddonMessagesProvider } from './providers/messages';
|
||||||
import { AddonMessagesOfflineProvider } from './providers/messages-offline';
|
import { AddonMessagesOfflineProvider } from './providers/messages-offline';
|
||||||
|
@ -69,7 +69,7 @@ export class AddonMessagesModule {
|
||||||
contentLinksDelegate: CoreContentLinksDelegate, indexLinkHandler: AddonMessagesIndexLinkHandler,
|
contentLinksDelegate: CoreContentLinksDelegate, indexLinkHandler: AddonMessagesIndexLinkHandler,
|
||||||
discussionLinkHandler: AddonMessagesDiscussionLinkHandler, sendMessageHandler: AddonMessagesSendMessageUserHandler,
|
discussionLinkHandler: AddonMessagesDiscussionLinkHandler, sendMessageHandler: AddonMessagesSendMessageUserHandler,
|
||||||
userDelegate: CoreUserDelegate, cronDelegate: CoreCronDelegate, syncHandler: AddonMessagesSyncCronHandler,
|
userDelegate: CoreUserDelegate, cronDelegate: CoreCronDelegate, syncHandler: AddonMessagesSyncCronHandler,
|
||||||
network: Network, messagesSync: AddonMessagesSyncProvider, appProvider: CoreAppProvider,
|
network: Network, zone: NgZone, messagesSync: AddonMessagesSyncProvider, appProvider: CoreAppProvider,
|
||||||
localNotifications: CoreLocalNotificationsProvider, messagesProvider: AddonMessagesProvider,
|
localNotifications: CoreLocalNotificationsProvider, messagesProvider: AddonMessagesProvider,
|
||||||
sitesProvider: CoreSitesProvider, linkHelper: CoreContentLinksHelperProvider, updateManager: CoreUpdateManagerProvider,
|
sitesProvider: CoreSitesProvider, linkHelper: CoreContentLinksHelperProvider, updateManager: CoreUpdateManagerProvider,
|
||||||
settingsHandler: AddonMessagesSettingsHandler, settingsDelegate: CoreSettingsDelegate,
|
settingsHandler: AddonMessagesSettingsHandler, settingsDelegate: CoreSettingsDelegate,
|
||||||
|
@ -88,8 +88,11 @@ export class AddonMessagesModule {
|
||||||
|
|
||||||
// Sync some discussions when device goes online.
|
// Sync some discussions when device goes online.
|
||||||
network.onConnect().subscribe(() => {
|
network.onConnect().subscribe(() => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
zone.run(() => {
|
||||||
messagesSync.syncAllDiscussions(undefined, true);
|
messagesSync.syncAllDiscussions(undefined, true);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const notificationClicked = (notification: any): void => {
|
const notificationClicked = (notification: any): void => {
|
||||||
messagesProvider.isMessagingEnabledForSite(notification.site).then(() => {
|
messagesProvider.isMessagingEnabledForSite(notification.site).then(() => {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, ViewChild } from '@angular/core';
|
import { Component, ViewChild, NgZone } from '@angular/core';
|
||||||
import { Content, IonicPage, ModalController, NavController, NavParams } from 'ionic-angular';
|
import { Content, IonicPage, ModalController, NavController, NavParams } from 'ionic-angular';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
import { CoreLoggerProvider } from '@providers/logger';
|
import { CoreLoggerProvider } from '@providers/logger';
|
||||||
|
@ -52,7 +52,7 @@ export class AddonModChatChatPage {
|
||||||
protected viewDestroyed = false;
|
protected viewDestroyed = false;
|
||||||
protected pollingRunning = false;
|
protected pollingRunning = false;
|
||||||
|
|
||||||
constructor(navParams: NavParams, logger: CoreLoggerProvider, network: Network, private navCtrl: NavController,
|
constructor(navParams: NavParams, logger: CoreLoggerProvider, network: Network, zone: NgZone, private navCtrl: NavController,
|
||||||
private chatProvider: AddonModChatProvider, private appProvider: CoreAppProvider, sitesProvider: CoreSitesProvider,
|
private chatProvider: AddonModChatProvider, private appProvider: CoreAppProvider, sitesProvider: CoreSitesProvider,
|
||||||
private modalCtrl: ModalController, private domUtils: CoreDomUtilsProvider, private textUtils: CoreTextUtilsProvider) {
|
private modalCtrl: ModalController, private domUtils: CoreDomUtilsProvider, private textUtils: CoreTextUtilsProvider) {
|
||||||
|
|
||||||
|
@ -63,8 +63,11 @@ export class AddonModChatChatPage {
|
||||||
this.currentUserBeep = 'beep ' + sitesProvider.getCurrentSiteUserId();
|
this.currentUserBeep = 'beep ' + sitesProvider.getCurrentSiteUserId();
|
||||||
this.isOnline = this.appProvider.isOnline();
|
this.isOnline = this.appProvider.isOnline();
|
||||||
this.onlineObserver = network.onchange().subscribe((online) => {
|
this.onlineObserver = network.onchange().subscribe((online) => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
zone.run(() => {
|
||||||
this.isOnline = this.appProvider.isOnline();
|
this.isOnline = this.appProvider.isOnline();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component, NgZone } from '@angular/core';
|
||||||
import { IonicPage, NavParams, ViewController } from 'ionic-angular';
|
import { IonicPage, NavParams, ViewController } from 'ionic-angular';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
|
@ -38,15 +38,18 @@ export class AddonModChatUsersPage {
|
||||||
protected sessionId: number;
|
protected sessionId: number;
|
||||||
protected onlineObserver: any;
|
protected onlineObserver: any;
|
||||||
|
|
||||||
constructor(navParams: NavParams, network: Network, private appProvider: CoreAppProvider,
|
constructor(navParams: NavParams, network: Network, zone: NgZone, private appProvider: CoreAppProvider,
|
||||||
private sitesProvider: CoreSitesProvider, private viewCtrl: ViewController,
|
private sitesProvider: CoreSitesProvider, private viewCtrl: ViewController,
|
||||||
private domUtils: CoreDomUtilsProvider, private chatProvider: AddonModChatProvider) {
|
private domUtils: CoreDomUtilsProvider, private chatProvider: AddonModChatProvider) {
|
||||||
this.sessionId = navParams.get('sessionId');
|
this.sessionId = navParams.get('sessionId');
|
||||||
this.isOnline = this.appProvider.isOnline();
|
this.isOnline = this.appProvider.isOnline();
|
||||||
this.currentUserId = this.sitesProvider.getCurrentSiteUserId();
|
this.currentUserId = this.sitesProvider.getCurrentSiteUserId();
|
||||||
this.onlineObserver = network.onchange().subscribe((online) => {
|
this.onlineObserver = network.onchange().subscribe((online) => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
zone.run(() => {
|
||||||
this.isOnline = this.appProvider.isOnline();
|
this.isOnline = this.appProvider.isOnline();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, OnDestroy, Optional } from '@angular/core';
|
import { Component, OnDestroy, Optional, NgZone } from '@angular/core';
|
||||||
import { IonicPage, NavParams, NavController, Content } from 'ionic-angular';
|
import { IonicPage, NavParams, NavController, Content } from 'ionic-angular';
|
||||||
import { Network } from '@ionic-native/network';
|
import { Network } from '@ionic-native/network';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
@ -69,7 +69,7 @@ export class AddonModFeedbackFormPage implements OnDestroy {
|
||||||
protected eventsProvider: CoreEventsProvider, protected feedbackSync: AddonModFeedbackSyncProvider, network: Network,
|
protected eventsProvider: CoreEventsProvider, protected feedbackSync: AddonModFeedbackSyncProvider, network: Network,
|
||||||
protected translate: TranslateService, protected loginHelper: CoreLoginHelperProvider,
|
protected translate: TranslateService, protected loginHelper: CoreLoginHelperProvider,
|
||||||
protected linkHelper: CoreContentLinksHelperProvider, sitesProvider: CoreSitesProvider,
|
protected linkHelper: CoreContentLinksHelperProvider, sitesProvider: CoreSitesProvider,
|
||||||
@Optional() private content: Content) {
|
@Optional() private content: Content, zone: NgZone) {
|
||||||
|
|
||||||
this.module = navParams.get('module');
|
this.module = navParams.get('module');
|
||||||
this.courseId = navParams.get('courseId');
|
this.courseId = navParams.get('courseId');
|
||||||
|
@ -82,8 +82,11 @@ export class AddonModFeedbackFormPage implements OnDestroy {
|
||||||
|
|
||||||
// Refresh online status when changes.
|
// Refresh online status when changes.
|
||||||
this.onlineObserver = network.onchange().subscribe((online) => {
|
this.onlineObserver = network.onchange().subscribe((online) => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
zone.run(() => {
|
||||||
this.offline = !online;
|
this.offline = !online;
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, Optional, OnDestroy, ViewChild } from '@angular/core';
|
import { Component, Optional, OnDestroy, ViewChild, NgZone } from '@angular/core';
|
||||||
import { IonicPage, NavParams, Content } from 'ionic-angular';
|
import { IonicPage, NavParams, Content } from 'ionic-angular';
|
||||||
import { Network } from '@ionic-native/network';
|
import { Network } from '@ionic-native/network';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
@ -78,6 +78,7 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
|
|
||||||
constructor(navParams: NavParams,
|
constructor(navParams: NavParams,
|
||||||
network: Network,
|
network: Network,
|
||||||
|
zone: NgZone,
|
||||||
private appProvider: CoreAppProvider,
|
private appProvider: CoreAppProvider,
|
||||||
private eventsProvider: CoreEventsProvider,
|
private eventsProvider: CoreEventsProvider,
|
||||||
private sitesProvider: CoreSitesProvider,
|
private sitesProvider: CoreSitesProvider,
|
||||||
|
@ -99,8 +100,11 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
|
|
||||||
this.isOnline = this.appProvider.isOnline();
|
this.isOnline = this.appProvider.isOnline();
|
||||||
this.onlineObserver = network.onchange().subscribe((online) => {
|
this.onlineObserver = network.onchange().subscribe((online) => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
zone.run(() => {
|
||||||
this.isOnline = this.appProvider.isOnline();
|
this.isOnline = this.appProvider.isOnline();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
this.isSplitViewOn = this.svComponent && this.svComponent.isOn();
|
this.isSplitViewOn = this.svComponent && this.svComponent.isOn();
|
||||||
|
|
||||||
this.discussionStr = translate.instant('addon.mod_forum.discussion');
|
this.discussionStr = translate.instant('addon.mod_forum.discussion');
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable, NgZone } from '@angular/core';
|
||||||
import { Platform } from 'ionic-angular';
|
import { Platform } from 'ionic-angular';
|
||||||
import { Badge } from '@ionic-native/badge';
|
import { Badge } from '@ionic-native/badge';
|
||||||
import { Push, PushObject, PushOptions } from '@ionic-native/push';
|
import { Push, PushObject, PushOptions } from '@ionic-native/push';
|
||||||
|
@ -65,7 +65,7 @@ export class AddonPushNotificationsProvider {
|
||||||
protected pushNotificationsDelegate: AddonPushNotificationsDelegate, protected sitesProvider: CoreSitesProvider,
|
protected pushNotificationsDelegate: AddonPushNotificationsDelegate, protected sitesProvider: CoreSitesProvider,
|
||||||
private badge: Badge, private localNotificationsProvider: CoreLocalNotificationsProvider,
|
private badge: Badge, private localNotificationsProvider: CoreLocalNotificationsProvider,
|
||||||
private utils: CoreUtilsProvider, private textUtils: CoreTextUtilsProvider, private push: Push,
|
private utils: CoreUtilsProvider, private textUtils: CoreTextUtilsProvider, private push: Push,
|
||||||
private configProvider: CoreConfigProvider, private device: Device) {
|
private configProvider: CoreConfigProvider, private device: Device, private zone: NgZone) {
|
||||||
this.logger = logger.getInstance('AddonPushNotificationsProvider');
|
this.logger = logger.getInstance('AddonPushNotificationsProvider');
|
||||||
this.appDB = appProvider.getDB();
|
this.appDB = appProvider.getDB();
|
||||||
this.appDB.createTablesFromSchema(this.tablesSchema);
|
this.appDB.createTablesFromSchema(this.tablesSchema);
|
||||||
|
@ -326,21 +326,30 @@ export class AddonPushNotificationsProvider {
|
||||||
const pushObject: PushObject = this.push.init(options);
|
const pushObject: PushObject = this.push.init(options);
|
||||||
|
|
||||||
pushObject.on('notification').subscribe((notification: any) => {
|
pushObject.on('notification').subscribe((notification: any) => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
this.zone.run(() => {
|
||||||
this.logger.log('Received a notification', notification);
|
this.logger.log('Received a notification', notification);
|
||||||
this.onMessageReceived(notification);
|
this.onMessageReceived(notification);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
pushObject.on('registration').subscribe((data: any) => {
|
pushObject.on('registration').subscribe((data: any) => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
this.zone.run(() => {
|
||||||
this.pushID = data.registrationId;
|
this.pushID = data.registrationId;
|
||||||
this.registerDeviceOnMoodle().catch((error) => {
|
this.registerDeviceOnMoodle().catch((error) => {
|
||||||
this.logger.warn('Can\'t register device', error);
|
this.logger.warn('Can\'t register device', error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
pushObject.on('error').subscribe((error: any) => {
|
pushObject.on('error').subscribe((error: any) => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
this.zone.run(() => {
|
||||||
this.logger.warn('Error with Push plugin', error);
|
this.logger.warn('Error with Push plugin', error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
this.logger.warn(ex);
|
this.logger.warn(ex);
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, NgZone } from '@angular/core';
|
||||||
import { Platform } from 'ionic-angular';
|
import { Platform } from 'ionic-angular';
|
||||||
import { StatusBar } from '@ionic-native/status-bar';
|
import { StatusBar } from '@ionic-native/status-bar';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
|
@ -33,7 +33,7 @@ export class MoodleMobileApp implements OnInit {
|
||||||
protected lastUrls = {};
|
protected lastUrls = {};
|
||||||
|
|
||||||
constructor(private platform: Platform, statusBar: StatusBar, logger: CoreLoggerProvider,
|
constructor(private platform: Platform, statusBar: StatusBar, logger: CoreLoggerProvider,
|
||||||
private eventsProvider: CoreEventsProvider, private loginHelper: CoreLoginHelperProvider,
|
private eventsProvider: CoreEventsProvider, private loginHelper: CoreLoginHelperProvider, private zone: NgZone,
|
||||||
private appProvider: CoreAppProvider, private langProvider: CoreLangProvider, private sitesProvider: CoreSitesProvider) {
|
private appProvider: CoreAppProvider, private langProvider: CoreLangProvider, private sitesProvider: CoreSitesProvider) {
|
||||||
this.logger = logger.getInstance('AppComponent');
|
this.logger = logger.getInstance('AppComponent');
|
||||||
|
|
||||||
|
@ -101,6 +101,8 @@ export class MoodleMobileApp implements OnInit {
|
||||||
|
|
||||||
// Handle app launched with a certain URL (custom URL scheme).
|
// Handle app launched with a certain URL (custom URL scheme).
|
||||||
(<any> window).handleOpenURL = (url: string): void => {
|
(<any> window).handleOpenURL = (url: string): void => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
this.zone.run(() => {
|
||||||
// First check that the URL hasn't been treated a few seconds ago. Sometimes this function is called more than once.
|
// First check that the URL hasn't been treated a few seconds ago. Sometimes this function is called more than once.
|
||||||
if (this.lastUrls[url] && Date.now() - this.lastUrls[url] < 3000) {
|
if (this.lastUrls[url] && Date.now() - this.lastUrls[url] < 3000) {
|
||||||
// Function called more than once, stop.
|
// Function called more than once, stop.
|
||||||
|
@ -112,6 +114,7 @@ export class MoodleMobileApp implements OnInit {
|
||||||
this.lastUrls[url] = Date.now();
|
this.lastUrls[url] = Date.now();
|
||||||
|
|
||||||
this.eventsProvider.trigger(CoreEventsProvider.APP_LAUNCHED_URL, url);
|
this.eventsProvider.trigger(CoreEventsProvider.APP_LAUNCHED_URL, url);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Listen for app launched URLs. If we receive one, check if it's a SSO authentication.
|
// Listen for app launched URLs. If we receive one, check if it's a SSO authentication.
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injector, Input } from '@angular/core';
|
import { Injector, Input, NgZone } from '@angular/core';
|
||||||
import { Content } from 'ionic-angular';
|
import { Content } from 'ionic-angular';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
|
@ -60,11 +60,15 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
|
||||||
this.modulePrefetchDelegate = injector.get(CoreCourseModulePrefetchDelegate);
|
this.modulePrefetchDelegate = injector.get(CoreCourseModulePrefetchDelegate);
|
||||||
|
|
||||||
const network = injector.get(Network);
|
const network = injector.get(Network);
|
||||||
|
const zone = injector.get(NgZone);
|
||||||
|
|
||||||
// Refresh online status when changes.
|
// Refresh online status when changes.
|
||||||
this.onlineObserver = network.onchange().subscribe((online) => {
|
this.onlineObserver = network.onchange().subscribe((online) => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
zone.run(() => {
|
||||||
this.isOnline = online;
|
this.isOnline = online;
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, OnDestroy } from '@angular/core';
|
import { Component, OnDestroy, NgZone } from '@angular/core';
|
||||||
import { IonicPage, NavController, NavParams, Platform, ModalController, Modal } from 'ionic-angular';
|
import { IonicPage, NavController, NavParams, Platform, ModalController, Modal } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
|
@ -69,7 +69,8 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
||||||
private coursesProvider: CoreCoursesProvider, private platform: Platform, private modalCtrl: ModalController,
|
private coursesProvider: CoreCoursesProvider, private platform: Platform, private modalCtrl: ModalController,
|
||||||
private translate: TranslateService, private eventsProvider: CoreEventsProvider,
|
private translate: TranslateService, private eventsProvider: CoreEventsProvider,
|
||||||
private courseOptionsDelegate: CoreCourseOptionsDelegate, private courseHelper: CoreCourseHelperProvider,
|
private courseOptionsDelegate: CoreCourseOptionsDelegate, private courseHelper: CoreCourseHelperProvider,
|
||||||
private courseProvider: CoreCourseProvider, private courseFormatDelegate: CoreCourseFormatDelegate) {
|
private courseProvider: CoreCourseProvider, private courseFormatDelegate: CoreCourseFormatDelegate,
|
||||||
|
private zone: NgZone) {
|
||||||
|
|
||||||
this.course = navParams.get('course');
|
this.course = navParams.get('course');
|
||||||
this.avoidOpenCourse = navParams.get('avoidOpenCourse');
|
this.avoidOpenCourse = navParams.get('avoidOpenCourse');
|
||||||
|
@ -292,9 +293,15 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
||||||
|
|
||||||
if (this.isDesktop || this.isMobile) {
|
if (this.isDesktop || this.isMobile) {
|
||||||
// Observe loaded pages in the InAppBrowser to check if the enrol process has ended.
|
// Observe loaded pages in the InAppBrowser to check if the enrol process has ended.
|
||||||
inAppLoadSubscription = window.on('loadstart').subscribe(urlLoaded);
|
inAppLoadSubscription = window.on('loadstart').subscribe((event) => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
this.zone.run(() => urlLoaded(event));
|
||||||
|
});
|
||||||
// Observe window closed.
|
// Observe window closed.
|
||||||
inAppExitSubscription = window.on('exit').subscribe(inAppClosed);
|
inAppExitSubscription = window.on('exit').subscribe(() => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
this.zone.run(inAppClosed);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isDesktop) {
|
if (this.isDesktop) {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable, NgZone } from '@angular/core';
|
||||||
import { Platform, App, NavController } from 'ionic-angular';
|
import { Platform, App, NavController } from 'ionic-angular';
|
||||||
import { Keyboard } from '@ionic-native/keyboard';
|
import { Keyboard } from '@ionic-native/keyboard';
|
||||||
import { Network } from '@ionic-native/network';
|
import { Network } from '@ionic-native/network';
|
||||||
|
@ -70,19 +70,24 @@ export class CoreAppProvider {
|
||||||
protected isKeyboardShown = false;
|
protected isKeyboardShown = false;
|
||||||
|
|
||||||
constructor(dbProvider: CoreDbProvider, private platform: Platform, private keyboard: Keyboard, private appCtrl: App,
|
constructor(dbProvider: CoreDbProvider, private platform: Platform, private keyboard: Keyboard, private appCtrl: App,
|
||||||
private network: Network, logger: CoreLoggerProvider, events: CoreEventsProvider) {
|
private network: Network, logger: CoreLoggerProvider, events: CoreEventsProvider, zone: NgZone) {
|
||||||
this.logger = logger.getInstance('CoreAppProvider');
|
this.logger = logger.getInstance('CoreAppProvider');
|
||||||
this.db = dbProvider.getDB(this.DBNAME);
|
this.db = dbProvider.getDB(this.DBNAME);
|
||||||
|
|
||||||
this.keyboard.onKeyboardShow().subscribe((data) => {
|
this.keyboard.onKeyboardShow().subscribe((data) => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
zone.run(() => {
|
||||||
this.isKeyboardShown = true;
|
this.isKeyboardShown = true;
|
||||||
events.trigger(CoreEventsProvider.KEYBOARD_CHANGE, this.isKeyboardShown);
|
events.trigger(CoreEventsProvider.KEYBOARD_CHANGE, this.isKeyboardShown);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
this.keyboard.onKeyboardHide().subscribe((data) => {
|
this.keyboard.onKeyboardHide().subscribe((data) => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
zone.run(() => {
|
||||||
this.isKeyboardShown = false;
|
this.isKeyboardShown = false;
|
||||||
events.trigger(CoreEventsProvider.KEYBOARD_CHANGE, this.isKeyboardShown);
|
events.trigger(CoreEventsProvider.KEYBOARD_CHANGE, this.isKeyboardShown);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable, NgZone } from '@angular/core';
|
||||||
import { Network } from '@ionic-native/network';
|
import { Network } from '@ionic-native/network';
|
||||||
import { CoreAppProvider } from './app';
|
import { CoreAppProvider } from './app';
|
||||||
import { CoreConfigProvider } from './config';
|
import { CoreConfigProvider } from './config';
|
||||||
|
@ -115,7 +115,7 @@ export class CoreCronDelegate {
|
||||||
protected queuePromise = Promise.resolve();
|
protected queuePromise = Promise.resolve();
|
||||||
|
|
||||||
constructor(logger: CoreLoggerProvider, private appProvider: CoreAppProvider, private configProvider: CoreConfigProvider,
|
constructor(logger: CoreLoggerProvider, private appProvider: CoreAppProvider, private configProvider: CoreConfigProvider,
|
||||||
private utils: CoreUtilsProvider, network: Network) {
|
private utils: CoreUtilsProvider, network: Network, zone: NgZone) {
|
||||||
this.logger = logger.getInstance('CoreCronDelegate');
|
this.logger = logger.getInstance('CoreCronDelegate');
|
||||||
|
|
||||||
this.appDB = this.appProvider.getDB();
|
this.appDB = this.appProvider.getDB();
|
||||||
|
@ -123,8 +123,11 @@ export class CoreCronDelegate {
|
||||||
|
|
||||||
// When the app is re-connected, start network handlers that were stopped.
|
// When the app is re-connected, start network handlers that were stopped.
|
||||||
network.onConnect().subscribe(() => {
|
network.onConnect().subscribe(() => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
zone.run(() => {
|
||||||
this.startNetworkHandlers();
|
this.startNetworkHandlers();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable, NgZone } from '@angular/core';
|
||||||
import { Network } from '@ionic-native/network';
|
import { Network } from '@ionic-native/network';
|
||||||
import { CoreAppProvider } from './app';
|
import { CoreAppProvider } from './app';
|
||||||
import { CoreEventsProvider } from './events';
|
import { CoreEventsProvider } from './events';
|
||||||
|
@ -436,7 +436,8 @@ export class CoreFilepoolProvider {
|
||||||
private sitesProvider: CoreSitesProvider, private wsProvider: CoreWSProvider, private textUtils: CoreTextUtilsProvider,
|
private sitesProvider: CoreSitesProvider, private wsProvider: CoreWSProvider, private textUtils: CoreTextUtilsProvider,
|
||||||
private utils: CoreUtilsProvider, private mimeUtils: CoreMimetypeUtilsProvider, private urlUtils: CoreUrlUtilsProvider,
|
private utils: CoreUtilsProvider, private mimeUtils: CoreMimetypeUtilsProvider, private urlUtils: CoreUrlUtilsProvider,
|
||||||
private timeUtils: CoreTimeUtilsProvider, private eventsProvider: CoreEventsProvider, initDelegate: CoreInitDelegate,
|
private timeUtils: CoreTimeUtilsProvider, private eventsProvider: CoreEventsProvider, initDelegate: CoreInitDelegate,
|
||||||
network: Network, private pluginFileDelegate: CorePluginFileDelegate, private domUtils: CoreDomUtilsProvider) {
|
network: Network, private pluginFileDelegate: CorePluginFileDelegate, private domUtils: CoreDomUtilsProvider,
|
||||||
|
zone: NgZone) {
|
||||||
this.logger = logger.getInstance('CoreFilepoolProvider');
|
this.logger = logger.getInstance('CoreFilepoolProvider');
|
||||||
|
|
||||||
this.appDB = this.appProvider.getDB();
|
this.appDB = this.appProvider.getDB();
|
||||||
|
@ -450,9 +451,12 @@ export class CoreFilepoolProvider {
|
||||||
|
|
||||||
// Start queue when device goes online.
|
// Start queue when device goes online.
|
||||||
network.onConnect().subscribe(() => {
|
network.onConnect().subscribe(() => {
|
||||||
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
zone.run(() => {
|
||||||
this.checkQueueProcessing();
|
this.checkQueueProcessing();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue