Merge branch 'master' into feature/mute

This commit is contained in:
Feruz M 2018-11-08 17:48:22 +02:00 committed by GitHub
commit 29adc8bc35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 34 deletions

View File

@ -1,5 +1,5 @@
import * as dsteem from 'dsteem'; import * as dsteem from 'dsteem';
import { getAccount } from './dsteem'; import { getUser } from './dsteem';
import { import {
setUserData, setUserData,
setAuthStatus, setAuthStatus,
@ -26,16 +26,12 @@ export const Login = (username, password) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// Get user account data from STEEM Blockchain // Get user account data from STEEM Blockchain
getAccount(username) getUser(username)
.then((result) => { .then((account) => {
if (isLoggedInUser(username)) { if (isLoggedInUser(username)) {
reject(new Error('You are already logged in, please try to add another account')); 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 // Public keys of user
publicKeys = { publicKeys = {
active: account.active.key_auths.map(x => x[0]), active: account.active.key_auths.map(x => x[0]),
@ -209,14 +205,14 @@ export const verifyPinCode = async (data) => {
} }
} else if (userData.authType === 'masterKey') { } else if (userData.authType === 'masterKey') {
const password = decryptKey(userData.masterKey, data.pinCode); const password = decryptKey(userData.masterKey, data.pinCode);
account = await getAccount(data.username); account = await getUser(data.username);
// Public keys of user // Public keys of user
const publicKeys = { const publicKeys = {
active: account[0].active.key_auths.map(x => x[0]), active: account.active.key_auths.map(x => x[0]),
memo: account[0].memo_key, memo: account.memo_key,
owner: account[0].owner.key_auths.map(x => x[0]), owner: account.owner.key_auths.map(x => x[0]),
posting: account[0].posting.key_auths.map(x => x[0]), posting: account.posting.key_auths.map(x => x[0]),
}; };
// Set private keys of user // Set private keys of user
const privateKeys = getPrivateKeys(data.username, password); const privateKeys = getPrivateKeys(data.username, password);
@ -268,18 +264,14 @@ export const verifyPinCode = async (data) => {
}; };
export const switchAccount = username => new Promise((resolve, reject) => { export const switchAccount = username => new Promise((resolve, reject) => {
getAccount(username) getUser(username)
.then((result) => { .then((account) => {
const account = result[0]; updateCurrentUsername(username).then(() => {
updateCurrentUsername(username) resolve(account);
.then(() => { }).catch(() => {
resolve(account); reject(new Error('Unknown error, please contact to eSteem.'));
}) });
.catch(() => { }).catch(() => {
reject(new Error('Unknown error, please contact to eSteem.'));
});
})
.catch(() => {
reject(new Error('Unknown error, please contact to eSteem.')); reject(new Error('Unknown error, please contact to eSteem.'));
}); });
}); });

View File

@ -1,4 +1,4 @@
import { getAccount } from '../../providers/steem/dsteem'; import { getUser } from '../../providers/steem/dsteem';
import { import {
FETCH_ACCOUNT_FAIL, FETCH_ACCOUNT_FAIL,
FETCHING_ACCOUNT, FETCHING_ACCOUNT,
@ -9,10 +9,10 @@ import {
export const fetchAccountFromSteem = (username, password) => (dispatch) => { export const fetchAccountFromSteem = (username, password) => (dispatch) => {
dispatch({ type: FETCHING_ACCOUNT }); dispatch({ type: FETCHING_ACCOUNT });
return getAccount(username) return getUser(username)
.then(res => dispatch({ .then(res => dispatch({
type: UPDATE_CURRENT_ACCOUNT, type: UPDATE_CURRENT_ACCOUNT,
payload: { ...res[0], password }, payload: { ...res, password },
})) }))
.catch(err => dispatch({ type: FETCH_ACCOUNT_FAIL, payload: err })); .catch(err => dispatch({ type: FETCH_ACCOUNT_FAIL, payload: err }));
}; };

View File

@ -1,4 +1,4 @@
import { getAccount } from '../../providers/steem/dsteem'; import { getUser } from '../../providers/steem/dsteem';
import { import {
FETCH_USER, FETCH_USER,
FETCH_USER_SUCCESS, FETCH_USER_SUCCESS,
@ -18,8 +18,8 @@ export function fetchAccount(user) {
return (dispatch) => { return (dispatch) => {
dispatch({ type: FETCH_USER }); dispatch({ type: FETCH_USER });
return getAccount(user) return getUser(user)
.then(res => dispatch({ type: FETCH_USER_SUCCESS, payload: res[0] })) .then(res => dispatch({ type: FETCH_USER_SUCCESS, payload: res }))
.catch(err => dispatch({ type: FETCH_USER_FAIL, payload: err })); .catch(err => dispatch({ type: FETCH_USER_FAIL, payload: err }));
}; };
} }

View File

@ -12,6 +12,8 @@ import { default as INITIAL } from '../../../constants/initial';
import { PinCodeScreen } from '..'; import { PinCodeScreen } from '..';
const DEFAULT_IMAGE = require('../../../assets/esteem.png');
class PinCodeContainer extends Component { class PinCodeContainer extends Component {
constructor(props) { constructor(props) {
super(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() { render() {
const { currentAccount } = this.props; const { currentAccount } = this.props;
const { informationText, isExistUser } = this.state; const { informationText, isExistUser } = this.state;
@ -126,6 +138,7 @@ class PinCodeContainer extends Component {
setPinCode={this._setPinCode} setPinCode={this._setPinCode}
showForgotButton={isExistUser} showForgotButton={isExistUser}
username={currentAccount ? currentAccount.name : 'unknow'} username={currentAccount ? currentAccount.name : 'unknow'}
avatar={this._getUserAvatar()}
/> />
); );
} }

View File

@ -1,8 +1,8 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Text, TouchableOpacity, View } from 'react-native'; 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'; import styles from './pinCodeStyles';
@ -46,13 +46,15 @@ class PinCodeScreen extends Component {
}; };
render() { render() {
const { informationText, showForgotButton, username } = this.props; const {
informationText, showForgotButton, username, avatar,
} = this.props;
const { pin } = this.state; const { pin } = this.state;
return ( return (
<Container style={styles.container}> <Container style={styles.container}>
<View style={styles.logoView}> <View style={styles.logoView}>
<Logo style={styles.logo} /> <Thumbnail source={avatar} />
</View> </View>
<View style={styles.titleView}> <View style={styles.titleView}>
<Text style={styles.title}>{`@${username}`}</Text> <Text style={styles.title}>{`@${username}`}</Text>

View File

@ -7,6 +7,8 @@ export default EStyleSheet.create({
}, },
logoView: { logoView: {
flex: 2, flex: 2,
justifyContent: 'center',
alignItems: 'center',
}, },
logo: { logo: {
width: '$deviceWidth / 7', width: '$deviceWidth / 7',