Merge pull request #579 from esteemapp/bugfix/#561

Fix for #561
This commit is contained in:
uğur erdal 2019-02-12 11:14:12 +03:00 committed by GitHub
commit e0d946e4ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -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);

View File

@ -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);
}