diff --git a/src/components/postView/container/postDisplayContainer.js b/src/components/postView/container/postDisplayContainer.js index 9ee39ec68..cfed84c95 100644 --- a/src/components/postView/container/postDisplayContainer.js +++ b/src/components/postView/container/postDisplayContainer.js @@ -76,7 +76,7 @@ class PostDisplayContainer extends Component { render() { const { - currentAccount, isLoggedIn, parentPost, post, + currentAccount, isLoggedIn, isNewPost, parentPost, post, } = this.props; return ( @@ -87,6 +87,7 @@ class PostDisplayContainer extends Component { handleOnReplyPress={this._handleOnReplyPress} handleOnVotersPress={this._handleOnVotersPress} isLoggedIn={isLoggedIn} + isNewPost={isNewPost} parentPost={parentPost} post={post} /> diff --git a/src/components/postView/view/postDisplayView.js b/src/components/postView/view/postDisplayView.js index 67f8038f0..2b215709d 100644 --- a/src/components/postView/view/postDisplayView.js +++ b/src/components/postView/view/postDisplayView.js @@ -40,9 +40,9 @@ class PostDisplayView extends PureComponent { // Component Life Cycles componentDidMount() { - const { currentAccount, isLoggedIn } = this.props; + const { currentAccount, isLoggedIn, isNewPost } = this.props; - if (isLoggedIn && currentAccount && currentAccount.name) { + if (isLoggedIn && currentAccount && currentAccount.name && !isNewPost) { userActivity(currentAccount.name, 10); } } diff --git a/src/providers/esteem/ePoint.js b/src/providers/esteem/ePoint.js index 780563dd9..676a95f43 100644 --- a/src/providers/esteem/ePoint.js +++ b/src/providers/esteem/ePoint.js @@ -1,29 +1,26 @@ import ePointApi from '../../config/ePoint'; -export const userActivity = (username, type, blockNumber = '', transactionNumber = '') => { - const params = { username, type }; +export const userActivity = (us, ty, bl = '', tx = '') => new Promise((resolve, reject) => { + const params = { us, ty }; - if (blockNumber) { - params.blockNumber = blockNumber; + if (bl) { + params.bl = bl; } - if (transactionNumber) { - params.transactionNumber = transactionNumber; + if (tx) { + params.tx = tx; } - try { - return ePointApi - .post('/usr-activity', { - us: username, - ty: type, - bn: blockNumber, - tn: transactionNumber, - }) - .then(res => res.data); - } catch (error) { - return null; - } -}; + ePointApi + .post('/usr-activity', params) + .then((res) => { + console.log(res); + resolve(res.data); + }) + .catch((error) => { + reject(error); + }); +}); export const transfer = (sender, receiver, amount) => new Promise((resolve, reject) => { ePointApi diff --git a/src/screens/login/container/loginContainer.js b/src/screens/login/container/loginContainer.js index 45e8bd236..6923c3bb3 100644 --- a/src/screens/login/container/loginContainer.js +++ b/src/screens/login/container/loginContainer.js @@ -6,6 +6,7 @@ import { injectIntl } from 'react-intl'; // Services and Actions import { login } from '../../../providers/steem/auth'; import { lookupAccounts } from '../../../providers/steem/dsteem'; +import { userActivity } from '../../../providers/esteem/ePoint'; import { failedAccount, addOtherAccount, @@ -55,13 +56,16 @@ class LoginContainer extends PureComponent { dispatch(openPinCodeModal()); setPinCodeState({ navigateTo: ROUTES.DRAWER.MAIN }); dispatch(loginAction(true)); + userActivity(result.name, 20); } }) .catch((err) => { - Alert.alert('Error', + Alert.alert( + 'Error', intl.formatMessage({ id: err.message, - })); + }), + ); dispatch(failedAccount(err.message)); this.setState({ isLoading: false }); }); diff --git a/src/screens/post/screen/postScreen.js b/src/screens/post/screen/postScreen.js index 5563652d8..a97e470da 100644 --- a/src/screens/post/screen/postScreen.js +++ b/src/screens/post/screen/postScreen.js @@ -47,6 +47,7 @@ class PostScreen extends PureComponent { fetchPost={fetchPost} isFetchComments={isFetchComments} isLoggedIn={isLoggedIn} + isNewPost={isNewPost} parentPost={parentPost} post={post} />