This commit is contained in:
Mustafa Buyukcelebi 2019-02-11 11:21:22 +03:00
parent 7921f822c3
commit 28411d6e81
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 AppCenter from 'appcenter';
import { NavigationActions } from 'react-navigation'; import { NavigationActions } from 'react-navigation';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import Push from 'appcenter-push';
// Constants // Constants
import en from 'react-intl/locale-data/en'; import en from 'react-intl/locale-data/en';
@ -228,15 +229,18 @@ class ApplicationContainer extends Component {
}; };
_getSettings = () => { _getSettings = () => {
const { dispatch, actions } = this.props; const { dispatch } = this.props;
getSettings().then((response) => { getSettings().then((response) => {
if (response) { if (response) {
if (response.isDarkTheme !== '') dispatch(isDarkTheme(response.isDarkTheme)); if (response.isDarkTheme !== '') dispatch(isDarkTheme(response.isDarkTheme));
if (response.language !== '') dispatch(setLanguage(response.language)); if (response.language !== '') dispatch(setLanguage(response.language));
if (response.notification !== '') dispatch(isNotificationOpen(response.notification));
if (response.server !== '') dispatch(setApi(response.server)); if (response.server !== '') dispatch(setApi(response.server));
if (response.upvotePercent !== '') dispatch(setUpvotePercent(Number(response.upvotePercent))); 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')); dispatch(setCurrency(response.currency !== '' ? response.currency : 'usd'));
@ -267,7 +271,7 @@ class ApplicationContainer extends Component {
username, username,
token, token,
system: Platform.OS, system: Platform.OS,
allows_notify: notificationSettings, allows_notify: Number(notificationSettings),
}; };
setPushToken(data).then(() => { setPushToken(data).then(() => {
setPushTokenSaved(true); setPushTokenSaved(true);

View File

@ -157,6 +157,7 @@ class SettingsContainer extends Component {
const isPushEnabled = await Push.isEnabled(); const isPushEnabled = await Push.isEnabled();
await Push.setEnabled(!isPushEnabled); await Push.setEnabled(!isPushEnabled);
this._setPushToken();
}; };
_handleButtonPress = (action, actionType) => { _handleButtonPress = (action, actionType) => {
@ -201,7 +202,7 @@ class SettingsContainer extends Component {
username, username,
token, token,
system: Platform.OS, system: Platform.OS,
allows_notify: isNotificationSettingsOpen, allows_notify: Number(isNotificationSettingsOpen),
}; };
setPushToken(data); setPushToken(data);
} }