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

View File

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

View File

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

View File

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