This commit is contained in:
Nouman Tahir 2023-06-26 16:51:57 +05:00
parent 137ef17be5
commit 104a6bfb3d
4 changed files with 17 additions and 15 deletions

View File

@ -96,8 +96,14 @@ const AccountsBottomSheetContainer = () => {
_currentAccount.username = _currentAccount.name;
if (!realmData[0]) {
realmData = await repairUserAccountData(_currentAccount.username, dispatch, intl, accounts, pinHash);
if(!realmData[0]){
realmData = await repairUserAccountData(
_currentAccount.username,
dispatch,
intl,
accounts,
pinHash,
);
if (!realmData[0]) {
return;
}
}

View File

@ -77,7 +77,6 @@ export default function (state = initialState, action) {
...state.otherAccounts.filter((item) => item.username !== action.payload.username),
action.payload,
]
: // add new account entry if it does not already exist
[...state.otherAccounts, action.payload],
isFetching: false,

View File

@ -83,7 +83,6 @@ import MigrationHelpers, {
import { deepLinkParser } from '../../../utils/deepLinkParser';
import bugsnapInstance from '../../../config/bugsnag';
let firebaseOnMessageListener: any = null;
let appStateSub: NativeEventSubscription | null = null;
let linkingEventSub: EventSubscription | null = null;
@ -106,7 +105,6 @@ class ApplicationContainer extends Component {
this._setNetworkListener();
linkingEventSub = Linking.addEventListener('url', this._handleOpenURL);
// TOOD: read initial URL
Linking.getInitialURL().then((url) => {
@ -401,7 +399,7 @@ class ApplicationContainer extends Component {
});
}
let realmObject:any[] = realmData.filter((data) => data.username === username);
let realmObject: any[] = realmData.filter((data) => data.username === username);
// reapir otherAccouts data is needed
// this repair must be done because code above makes sure every entry is realmData is a valid one
@ -410,9 +408,9 @@ class ApplicationContainer extends Component {
if (!realmObject[0]) {
// means current logged in user keys data not present, re-verify required
realmObject = await this._repairUserAccountData(username);
//disrupt routine if repair helper fails
if(!realmObject[0]){
// disrupt routine if repair helper fails
if (!realmObject[0]) {
return null;
}
}
@ -681,8 +679,8 @@ class ApplicationContainer extends Component {
if (!realmData[0]) {
realmData = await this._repairUserAccountData(targetAccount.username);
//disrupt routine if repair helper fails
if(!realmData[0]) {
// disrupt routine if repair helper fails
if (!realmData[0]) {
return;
}
}

View File

@ -169,7 +169,7 @@ export const migrateUserEncryption = async (dispatch, currentAccount, encUserPin
};
export const repairUserAccountData = async (username, dispatch, intl, accounts, pinHash) => {
let authData:any[] = [];
let authData: any[] = [];
try {
// clean realm data just in case, to avoid already logged error
await removeUserData(username);
@ -200,9 +200,8 @@ export const repairUserAccountData = async (username, dispatch, intl, accounts,
dispatch(updateCurrentAccount({ ..._userAccount }));
//compile authData for return;
// compile authData for return;
authData = [_userAccount.local];
} catch (err) {
// keys data corrupted, ask user to verify login
await delay(500);
@ -230,7 +229,7 @@ export const repairUserAccountData = async (username, dispatch, intl, accounts,
);
}
return authData
return authData;
};
export const repairOtherAccountsData = (accounts, realmAuthData, dispatch) => {