mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
Merge branch 'migration-2' of github.com:esteemapp/esteem-mobile into bugfix/remove-realm
This commit is contained in:
commit
b94cff39dc
@ -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];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user