mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-03 03:25:24 +03:00
logout user when delete account is pressed and show toast
This commit is contained in:
parent
12f84ab066
commit
d43985d2c5
@ -549,6 +549,11 @@
|
||||
"confirm_report_title":"Confirm Report!",
|
||||
"confirm_report_body":"Are you sure you want report?"
|
||||
},
|
||||
"delete": {
|
||||
"confirm_delete_title": "Confirm Delete",
|
||||
"confirm_delete_body": "Are you sure you want to delete account? It will erase all of your data",
|
||||
"request_sent": "Your request for deletion is sent"
|
||||
},
|
||||
"favorites": {
|
||||
"title": "Favorites",
|
||||
"load_error": "Could not load favorites",
|
||||
|
@ -41,9 +41,10 @@ import {
|
||||
setIsBiometricEnabled,
|
||||
setEncryptedUnlockPin,
|
||||
setHidePostsThumbnails,
|
||||
logout,
|
||||
} from '../../../redux/actions/applicationActions';
|
||||
import { toastNotification } from '../../../redux/actions/uiAction';
|
||||
import { setPushToken, getNodes } from '../../../providers/ecency/ecency';
|
||||
import { showActionModal, toastNotification } from '../../../redux/actions/uiAction';
|
||||
import { setPushToken, getNodes, deleteAccount } from '../../../providers/ecency/ecency';
|
||||
import { checkClient } from '../../../providers/hive/dhive';
|
||||
import { removeOtherAccount, updateCurrentAccount } from '../../../redux/actions/accountAction';
|
||||
// Middleware
|
||||
@ -314,9 +315,9 @@ class SettingsContainer extends Component {
|
||||
break;
|
||||
|
||||
case settingsTypes.DELETE_ACCOUNT:
|
||||
console.log('delete account');
|
||||
|
||||
this._handleDeleteAccount();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -394,6 +395,51 @@ class SettingsContainer extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
_handleDeleteAccount = () => {
|
||||
const { dispatch, intl, currentAccount } = this.props as any;
|
||||
|
||||
const _onConfirm = () => {
|
||||
deleteAccount(currentAccount.username)
|
||||
.then(() => {
|
||||
dispatch(
|
||||
toastNotification(
|
||||
intl.formatMessage({
|
||||
id: 'delete.request_sent',
|
||||
}),
|
||||
),
|
||||
);
|
||||
dispatch(logout());
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch(
|
||||
toastNotification(
|
||||
intl.formatMessage({
|
||||
id: 'delete.request_sent',
|
||||
}),
|
||||
),
|
||||
);
|
||||
dispatch(logout());
|
||||
});
|
||||
};
|
||||
|
||||
dispatch(
|
||||
showActionModal({
|
||||
title: intl.formatMessage({ id: 'delete.confirm_delete_title' }),
|
||||
body: intl.formatMessage({ id: 'delete.confirm_delete_body' }),
|
||||
buttons: [
|
||||
{
|
||||
text: intl.formatMessage({ id: 'alert.cancel' }),
|
||||
onPress: () => {},
|
||||
},
|
||||
{
|
||||
text: intl.formatMessage({ id: 'alert.delete' }),
|
||||
onPress: _onConfirm,
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
}
|
||||
_clearUserData = async () => {
|
||||
const { otherAccounts, dispatch } = this.props;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user