Merge pull request #1252 from esteemapp/bugfix/notification-disable

Bugfix/notification disable
This commit is contained in:
uğur erdal 2019-11-07 19:04:38 +03:00 committed by GitHub
commit 7733eeb6dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 27 deletions

View File

@ -359,12 +359,7 @@ class PostsView extends Component {
render() {
const { refreshing, posts, isShowFilterBar } = this.state;
const {
filterOptions,
selectedOptionIndex,
isHideImage,
handleImagesHide,
} = this.props;
const { filterOptions, selectedOptionIndex, isHideImage, handleImagesHide } = this.props;
return (
<View style={styles.container}>

View File

@ -236,10 +236,6 @@ class SettingsContainer extends Component {
dispatch(changeNotificationSettings({ action, type: actionType }));
setNotificationSettings({ action, type: actionType });
if (actionType === 'notification') {
await Push.setEnabled(action);
this._setPushToken(action ? [1, 2, 3, 4, 5, 6] : notifyTypes);
} else {
Object.keys(notificationDetails).map(item => {
const notificationType = item.replace('Notification', '');
@ -251,6 +247,12 @@ class SettingsContainer extends Component {
notifyTypes.push(notifyTypesConst[notificationType]);
}
});
notifyTypes.sort();
if (actionType === 'notification') {
await Push.setEnabled(action);
this._setPushToken(action ? notifyTypes : []);
} else {
this._setPushToken(notifyTypes);
}
};
@ -286,21 +288,25 @@ class SettingsContainer extends Component {
};
_setPushToken = async notifyTypes => {
const { isNotificationSettingsOpen, isLoggedIn, username } = this.props;
const { isLoggedIn, otherAccounts = [] } = this.props;
if (isLoggedIn) {
const token = await AppCenter.getInstallId();
getExistUser().then(isExistUser => {
if (isExistUser) {
otherAccounts.forEach(item => {
const { isNotificationSettingsOpen } = this.props;
const data = {
username,
username: item.username,
token,
system: Platform.OS,
allows_notify: Number(isNotificationSettingsOpen),
notify_types: notifyTypes,
};
setPushToken(data);
});
}
});
}
@ -401,6 +407,7 @@ const mapStateToProps = state => ({
username: state.account.currentAccount && state.account.currentAccount.name,
currentAccount: state.account.currentAccount,
otherAccounts: state.account.otherAccounts,
});
export default injectIntl(connect(mapStateToProps)(SettingsContainer));