Merge branch 'migration-2' of github.com:esteemapp/esteem-mobile into bugfix/remove-realm

This commit is contained in:
Mustafa Buyukcelebi 2019-11-08 11:36:40 +03:00
commit b94cff39dc
4 changed files with 26 additions and 25 deletions

View File

@ -107,7 +107,7 @@ class TransferContainer extends Component {
return validUsers;
};
_transferToAccount = (from, destination, amount, memo) => {
_transferToAccount = async (from, destination, amount, memo) => {
const { pinCode, navigation, dispatch, intl } = this.props;
let { currentAccount } = this.props;
const { selectedAccount } = this.state;
@ -160,7 +160,7 @@ class TransferContainer extends Component {
break;
}
if (!currentAccount.local) {
const realmData = getUserDataWithUsername(currentAccount.name);
const realmData = await getUserDataWithUsername(currentAccount.name);
currentAccount.local = realmData[0];
}

View File

@ -32,7 +32,7 @@ export const login = async (username, password, isPinCodeOpen) => {
if (!account) {
return Promise.reject(new Error('auth.invalid_username'));
}
if (isLoggedInUser(username)) {
if (await isLoggedInUser(username)) {
return Promise.reject(new Error('auth.already_logged'));
}
// Public keys of user
@ -144,7 +144,7 @@ export const loginWithSC2 = async (code, isPinCodeOpen) => {
account.local.avatar = avatar;
}
if (isLoggedInUser(account.name)) {
if (await isLoggedInUser(account.name)) {
reject(new Error('auth.already_logged'));
}
@ -167,7 +167,7 @@ export const loginWithSC2 = async (code, isPinCodeOpen) => {
export const setUserDataWithPinCode = async data => {
try {
const result = getUserDataWithUsername(data.username);
const result = await getUserDataWithUsername(data.username);
const userData = result[0];
if (!data.password) {
@ -234,7 +234,7 @@ export const updatePinCode = data =>
export const verifyPinCode = async data => {
const pinHash = await getPinCode();
const result = getUserDataWithUsername(data.username);
const result = await getUserDataWithUsername(data.username);
const userData = result[0];
// This is migration for new pin structure, it will remove v2.2
@ -338,8 +338,8 @@ export const getUpdatedUserData = (userData, data) => {
};
};
const isLoggedInUser = username => {
const result = getUserDataWithUsername(username);
const isLoggedInUser = async username => {
const result = await getUserDataWithUsername(username);
if (result.length > 0) {
return true;
}

View File

@ -637,7 +637,7 @@ class ApplicationContainer extends Component {
const accountData = await switchAccount(targetAccountUsername);
const realmData = getUserDataWithUsername(targetAccountUsername);
const realmData = await getUserDataWithUsername(targetAccountUsername);
const _currentAccount = accountData;
_currentAccount.username = accountData.name;
[_currentAccount.local] = realmData;

View File

@ -207,21 +207,22 @@ class PinCodeContainer extends Component {
verifyPinCode(pinData)
.then(() => {
this._savePinCode(pin);
const realmData = getUserDataWithUsername(currentAccount.name);
const _currentAccount = currentAccount;
_currentAccount.username = _currentAccount.name;
[_currentAccount.local] = realmData;
dispatch(updateCurrentAccount({ ..._currentAccount }));
dispatch(closePinCodeModal());
if (callback) callback(pin, oldPinCode);
if (navigateTo) {
const navigateAction = NavigationActions.navigate({
routeName: navigateTo,
params: navigateParams,
action: NavigationActions.navigate({ routeName: navigateTo }),
});
dispatch(navigateAction);
}
getUserDataWithUsername(currentAccount.name).then(realmData => {
const _currentAccount = currentAccount;
_currentAccount.username = _currentAccount.name;
[_currentAccount.local] = realmData;
dispatch(updateCurrentAccount({ ..._currentAccount }));
dispatch(closePinCodeModal());
if (callback) callback(pin, oldPinCode);
if (navigateTo) {
const navigateAction = NavigationActions.navigate({
routeName: navigateTo,
params: navigateParams,
action: NavigationActions.navigate({ routeName: navigateTo }),
});
dispatch(navigateAction);
}
});
})
.catch(err => {
Alert.alert(
@ -246,7 +247,7 @@ class PinCodeContainer extends Component {
const { intl, currentAccount, applicationPinCode } = this.props;
const { isExistUser, pinCode } = this.state;
const realmData = getUserDataWithUsername(currentAccount.name);
const realmData = await getUserDataWithUsername(currentAccount.name);
const userData = realmData[0];
// For exist users