removed duplicated code from accoutn switcher

This commit is contained in:
Nouman Tahir 2021-06-29 14:48:34 +05:00
parent 9655fd383d
commit b6b80e7a7b

View File

@ -53,21 +53,14 @@ const AccountsBottomSheetContainer = ({ navigation }) => {
(account) => account.username === switchingAccount.username, (account) => account.username === switchingAccount.username,
)[0]; )[0];
// control user persist whole data or just username // if account data has persistet content use that first
//to avoid lag
if (accountData.name) { if (accountData.name) {
accountData.username = accountData.name; accountData.username = accountData.name;
dispatch(updateCurrentAccount(accountData)); dispatch(updateCurrentAccount(accountData));
//dispatch(isRenderRequired(true)); }
const upToDateCurrentAccount = await switchAccount(accountData.name); //fetch upto data account data nd update current account;
const realmData = await getUserDataWithUsername(accountData.name);
upToDateCurrentAccount.username = upToDateCurrentAccount.name;
upToDateCurrentAccount.local = realmData[0];
dispatch(updateCurrentAccount(upToDateCurrentAccount));
} else {
const _currentAccount = await switchAccount(accountData.username); const _currentAccount = await switchAccount(accountData.username);
const realmData = await getUserDataWithUsername(accountData.username); const realmData = await getUserDataWithUsername(accountData.username);
@ -75,8 +68,7 @@ const AccountsBottomSheetContainer = ({ navigation }) => {
_currentAccount.local = realmData[0]; _currentAccount.local = realmData[0];
dispatch(updateCurrentAccount(_currentAccount)); dispatch(updateCurrentAccount(_currentAccount));
//dispatch(isRenderRequired(true));
}
}; };
return ( return (