From 28411d6e811b02a0300dea4078fed9a10bef12e2 Mon Sep 17 00:00:00 2001 From: Mustafa Buyukcelebi Date: Mon, 11 Feb 2019 11:21:22 +0300 Subject: [PATCH] Fix for #561 --- .../application/container/applicationContainer.js | 10 +++++++--- src/screens/settings/container/settingsContainer.js | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js index 68abc53a7..510af2739 100644 --- a/src/screens/application/container/applicationContainer.js +++ b/src/screens/application/container/applicationContainer.js @@ -8,6 +8,7 @@ import Config from 'react-native-config'; import AppCenter from 'appcenter'; import { NavigationActions } from 'react-navigation'; import { bindActionCreators } from 'redux'; +import Push from 'appcenter-push'; // Constants import en from 'react-intl/locale-data/en'; @@ -228,15 +229,18 @@ class ApplicationContainer extends Component { }; _getSettings = () => { - const { dispatch, actions } = this.props; + const { dispatch } = this.props; getSettings().then((response) => { if (response) { if (response.isDarkTheme !== '') dispatch(isDarkTheme(response.isDarkTheme)); if (response.language !== '') dispatch(setLanguage(response.language)); - if (response.notification !== '') dispatch(isNotificationOpen(response.notification)); if (response.server !== '') dispatch(setApi(response.server)); if (response.upvotePercent !== '') dispatch(setUpvotePercent(Number(response.upvotePercent))); + if (response.notification !== '') { + dispatch(isNotificationOpen(response.notification)); + Push.setEnabled(response.notification); + } dispatch(setCurrency(response.currency !== '' ? response.currency : 'usd')); @@ -267,7 +271,7 @@ class ApplicationContainer extends Component { username, token, system: Platform.OS, - allows_notify: notificationSettings, + allows_notify: Number(notificationSettings), }; setPushToken(data).then(() => { setPushTokenSaved(true); diff --git a/src/screens/settings/container/settingsContainer.js b/src/screens/settings/container/settingsContainer.js index db489c9c0..9c40b9076 100644 --- a/src/screens/settings/container/settingsContainer.js +++ b/src/screens/settings/container/settingsContainer.js @@ -157,6 +157,7 @@ class SettingsContainer extends Component { const isPushEnabled = await Push.isEnabled(); await Push.setEnabled(!isPushEnabled); + this._setPushToken(); }; _handleButtonPress = (action, actionType) => { @@ -201,7 +202,7 @@ class SettingsContainer extends Component { username, token, system: Platform.OS, - allows_notify: isNotificationSettingsOpen, + allows_notify: Number(isNotificationSettingsOpen), }; setPushToken(data); }