mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-28 01:52:56 +03:00
Merge branch 'master' into feature/mute
This commit is contained in:
commit
29adc8bc35
@ -1,5 +1,5 @@
|
||||
import * as dsteem from 'dsteem';
|
||||
import { getAccount } from './dsteem';
|
||||
import { getUser } from './dsteem';
|
||||
import {
|
||||
setUserData,
|
||||
setAuthStatus,
|
||||
@ -26,16 +26,12 @@ export const Login = (username, password) => {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// Get user account data from STEEM Blockchain
|
||||
getAccount(username)
|
||||
.then((result) => {
|
||||
getUser(username)
|
||||
.then((account) => {
|
||||
if (isLoggedInUser(username)) {
|
||||
reject(new Error('You are already logged in, please try to add another account'));
|
||||
} else if (result.length < 1) {
|
||||
reject(new Error('Invalid credentails, please check and try again'));
|
||||
}
|
||||
|
||||
const account = result[0];
|
||||
|
||||
// Public keys of user
|
||||
publicKeys = {
|
||||
active: account.active.key_auths.map(x => x[0]),
|
||||
@ -209,14 +205,14 @@ export const verifyPinCode = async (data) => {
|
||||
}
|
||||
} else if (userData.authType === 'masterKey') {
|
||||
const password = decryptKey(userData.masterKey, data.pinCode);
|
||||
account = await getAccount(data.username);
|
||||
account = await getUser(data.username);
|
||||
|
||||
// Public keys of user
|
||||
const publicKeys = {
|
||||
active: account[0].active.key_auths.map(x => x[0]),
|
||||
memo: account[0].memo_key,
|
||||
owner: account[0].owner.key_auths.map(x => x[0]),
|
||||
posting: account[0].posting.key_auths.map(x => x[0]),
|
||||
active: account.active.key_auths.map(x => x[0]),
|
||||
memo: account.memo_key,
|
||||
owner: account.owner.key_auths.map(x => x[0]),
|
||||
posting: account.posting.key_auths.map(x => x[0]),
|
||||
};
|
||||
// Set private keys of user
|
||||
const privateKeys = getPrivateKeys(data.username, password);
|
||||
@ -268,18 +264,14 @@ export const verifyPinCode = async (data) => {
|
||||
};
|
||||
|
||||
export const switchAccount = username => new Promise((resolve, reject) => {
|
||||
getAccount(username)
|
||||
.then((result) => {
|
||||
const account = result[0];
|
||||
updateCurrentUsername(username)
|
||||
.then(() => {
|
||||
resolve(account);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('Unknown error, please contact to eSteem.'));
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
getUser(username)
|
||||
.then((account) => {
|
||||
updateCurrentUsername(username).then(() => {
|
||||
resolve(account);
|
||||
}).catch(() => {
|
||||
reject(new Error('Unknown error, please contact to eSteem.'));
|
||||
});
|
||||
}).catch(() => {
|
||||
reject(new Error('Unknown error, please contact to eSteem.'));
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getAccount } from '../../providers/steem/dsteem';
|
||||
import { getUser } from '../../providers/steem/dsteem';
|
||||
import {
|
||||
FETCH_ACCOUNT_FAIL,
|
||||
FETCHING_ACCOUNT,
|
||||
@ -9,10 +9,10 @@ import {
|
||||
export const fetchAccountFromSteem = (username, password) => (dispatch) => {
|
||||
dispatch({ type: FETCHING_ACCOUNT });
|
||||
|
||||
return getAccount(username)
|
||||
return getUser(username)
|
||||
.then(res => dispatch({
|
||||
type: UPDATE_CURRENT_ACCOUNT,
|
||||
payload: { ...res[0], password },
|
||||
payload: { ...res, password },
|
||||
}))
|
||||
.catch(err => dispatch({ type: FETCH_ACCOUNT_FAIL, payload: err }));
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getAccount } from '../../providers/steem/dsteem';
|
||||
import { getUser } from '../../providers/steem/dsteem';
|
||||
import {
|
||||
FETCH_USER,
|
||||
FETCH_USER_SUCCESS,
|
||||
@ -18,8 +18,8 @@ export function fetchAccount(user) {
|
||||
return (dispatch) => {
|
||||
dispatch({ type: FETCH_USER });
|
||||
|
||||
return getAccount(user)
|
||||
.then(res => dispatch({ type: FETCH_USER_SUCCESS, payload: res[0] }))
|
||||
return getUser(user)
|
||||
.then(res => dispatch({ type: FETCH_USER_SUCCESS, payload: res }))
|
||||
.catch(err => dispatch({ type: FETCH_USER_FAIL, payload: err }));
|
||||
};
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import { default as INITIAL } from '../../../constants/initial';
|
||||
|
||||
import { PinCodeScreen } from '..';
|
||||
|
||||
const DEFAULT_IMAGE = require('../../../assets/esteem.png');
|
||||
|
||||
class PinCodeContainer extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@ -117,6 +119,16 @@ class PinCodeContainer extends Component {
|
||||
}
|
||||
});
|
||||
|
||||
_getUserAvatar = () => {
|
||||
const { currentAccount } = this.props;
|
||||
if (Object.keys(currentAccount).length === 0) return DEFAULT_IMAGE;
|
||||
if (Object.keys(currentAccount.about).length === 0) return DEFAULT_IMAGE;
|
||||
if (Object.keys(currentAccount.about.profile).length !== 0) {
|
||||
return { uri: currentAccount.about.profile.profile_image };
|
||||
}
|
||||
return DEFAULT_IMAGE;
|
||||
};
|
||||
|
||||
render() {
|
||||
const { currentAccount } = this.props;
|
||||
const { informationText, isExistUser } = this.state;
|
||||
@ -126,6 +138,7 @@ class PinCodeContainer extends Component {
|
||||
setPinCode={this._setPinCode}
|
||||
showForgotButton={isExistUser}
|
||||
username={currentAccount ? currentAccount.name : 'unknow'}
|
||||
avatar={this._getUserAvatar()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Text, TouchableOpacity, View } from 'react-native';
|
||||
import { Container } from 'native-base';
|
||||
import { Container, Thumbnail } from 'native-base';
|
||||
|
||||
import { Logo, NumericKeyboard, PinAnimatedInput } from '../../../components';
|
||||
import { NumericKeyboard, PinAnimatedInput } from '../../../components';
|
||||
|
||||
import styles from './pinCodeStyles';
|
||||
|
||||
@ -46,13 +46,15 @@ class PinCodeScreen extends Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { informationText, showForgotButton, username } = this.props;
|
||||
const {
|
||||
informationText, showForgotButton, username, avatar,
|
||||
} = this.props;
|
||||
const { pin } = this.state;
|
||||
|
||||
return (
|
||||
<Container style={styles.container}>
|
||||
<View style={styles.logoView}>
|
||||
<Logo style={styles.logo} />
|
||||
<Thumbnail source={avatar} />
|
||||
</View>
|
||||
<View style={styles.titleView}>
|
||||
<Text style={styles.title}>{`@${username}`}</Text>
|
||||
|
@ -7,6 +7,8 @@ export default EStyleSheet.create({
|
||||
},
|
||||
logoView: {
|
||||
flex: 2,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
},
|
||||
logo: {
|
||||
width: '$deviceWidth / 7',
|
||||
|
Loading…
Reference in New Issue
Block a user