Refactoring for application container

This commit is contained in:
Mustafa Buyukcelebi 2019-07-11 11:57:36 +03:00
parent 7ff067f5af
commit e2554884be

View File

@ -70,7 +70,7 @@ import {
isDefaultFooter, isDefaultFooter,
} from '../../../redux/actions/applicationActions'; } from '../../../redux/actions/applicationActions';
// Container // Screens
import ApplicationScreen from '../screen/applicationScreen'; import ApplicationScreen from '../screen/applicationScreen';
import { Launch } from '../..'; import { Launch } from '../..';
@ -334,14 +334,14 @@ class ApplicationContainer extends Component {
}; };
}; };
_logout = async () => { _logout = () => {
const { const {
otherAccounts, otherAccounts,
currentAccount: { name, local }, currentAccount: { name, local },
dispatch, dispatch,
} = this.props; } = this.props;
await removeUserData(name) removeUserData(name)
.then(async () => { .then(async () => {
const _otherAccounts = otherAccounts.filter(user => user.username !== name); const _otherAccounts = otherAccounts.filter(user => user.username !== name);
@ -388,14 +388,14 @@ class ApplicationContainer extends Component {
_switchAccount = async targetAccountUsername => { _switchAccount = async targetAccountUsername => {
const { dispatch } = this.props; const { dispatch } = this.props;
await switchAccount(targetAccountUsername).then(accountData => { const accountData = await switchAccount(targetAccountUsername);
const realmData = getUserDataWithUsername(targetAccountUsername); const realmData = getUserDataWithUsername(targetAccountUsername);
const _currentAccount = accountData; const _currentAccount = accountData;
_currentAccount.username = accountData.name; _currentAccount.username = accountData.name;
[_currentAccount.local] = realmData; [_currentAccount.local] = realmData;
dispatch(updateCurrentAccount(_currentAccount)); dispatch(updateCurrentAccount(_currentAccount));
});
}; };
render() { render() {