made some changes to account data repair routines

This commit is contained in:
noumantahir 2023-06-17 22:26:42 +05:00
parent 411ee5b77b
commit 6925307256
2 changed files with 7 additions and 9 deletions

View File

@ -381,21 +381,18 @@ class ApplicationContainer extends Component {
} = this.props;
let realmData = [];
if (currentAccount?.username) {
if (currentAccount?.name) {
dispatch(login(true));
const { username } = currentAccount;
const username = currentAccount.name;
let reduxAccountNames = otherAccounts.map((account) => account.username);
const userData = await getUserData();
if (userData && userData.length > 0) {
realmData = userData;
userData.forEach((accountData, index) => {
reduxAccountNames = reduxAccountNames.filter(
(username) => username !== accountData.username,
);
if (
!accountData ||
(!accountData.accessToken &&

View File

@ -228,10 +228,11 @@ export const repairUserAccountData = async (username, dispatch, intl, accounts,
export const repairOtherAccountsData = (accounts, realmAuthData, dispatch, ) => {
accounts.forEach((account) => {
const accRealmData = realmAuthData.find(data => data.username === account.username)
if(!account.local?.accessToken && accRealmData){
const accRealmData = realmAuthData.find(data => data.username === account.name)
if((!account.local?.accessToken || !account.username) && accRealmData){
account.local = accRealmData;
dispatch(updateOtherAccount({...account}))
account.username = accRealmData.username;
dispatch(updateOtherAccount({...account}));
}
})
}