From 3fd0500286530b6c876bf774b2053e9019ce6066 Mon Sep 17 00:00:00 2001 From: Albert Gasset Date: Mon, 10 Sep 2018 11:37:39 +0200 Subject: [PATCH] MOBILE-2567 pushnotifications: Fix redirect when app is open --- src/addon/messages/messages.module.ts | 2 +- .../pushnotifications/providers/pushnotifications.ts | 8 +++++--- src/addon/pushnotifications/pushnotifications.module.ts | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/addon/messages/messages.module.ts b/src/addon/messages/messages.module.ts index 7eab2f334..5413893ae 100644 --- a/src/addon/messages/messages.module.ts +++ b/src/addon/messages/messages.module.ts @@ -102,7 +102,7 @@ export class AddonMessagesModule { return; } - messagesProvider.invalidateDiscussionsCache().finally(() => { + messagesProvider.invalidateDiscussionsCache(notification.site).finally(() => { linkHelper.goInSite(undefined, 'AddonMessagesIndexPage', undefined, notification.site); }); }); diff --git a/src/addon/pushnotifications/providers/pushnotifications.ts b/src/addon/pushnotifications/providers/pushnotifications.ts index 32b608c3f..348935a7f 100644 --- a/src/addon/pushnotifications/providers/pushnotifications.ts +++ b/src/addon/pushnotifications/providers/pushnotifications.ts @@ -344,9 +344,11 @@ export class AddonPushNotificationsProvider { // Execute the callback in the Angular zone, so change detection doesn't stop working. this.zone.run(() => { this.pushID = data.registrationId; - this.registerDeviceOnMoodle().catch((error) => { - this.logger.warn('Can\'t register device', error); - }); + if (this.sitesProvider.isLoggedIn()) { + this.registerDeviceOnMoodle().catch((error) => { + this.logger.warn('Can\'t register device', error); + }); + } }); }); diff --git a/src/addon/pushnotifications/pushnotifications.module.ts b/src/addon/pushnotifications/pushnotifications.module.ts index 257aae6eb..6de574ecc 100644 --- a/src/addon/pushnotifications/pushnotifications.module.ts +++ b/src/addon/pushnotifications/pushnotifications.module.ts @@ -70,7 +70,7 @@ export class AddonPushNotificationsModule { // Listen for local notification clicks (generated by the app). localNotificationsProvider.registerClick(AddonPushNotificationsProvider.COMPONENT, - pushNotificationsProvider.notificationClicked); + pushNotificationsProvider.notificationClicked.bind(pushNotificationsProvider)); // Allow migrating the table from the old app to the new schema. updateManager.registerAppTableMigration({