This commit is contained in:
Mustafa Buyukcelebi 2019-02-11 11:21:22 +03:00
parent 677d2bdc16
commit 5415ea54f3
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);
}