From 07b935069ac966c6902bef79366cf2f24339dac0 Mon Sep 17 00:00:00 2001 From: ue Date: Thu, 29 Aug 2019 21:44:28 +0300 Subject: [PATCH] fixed steem commenct promote posts json datas --- src/containers/pointsContainer.js | 8 +--- .../boostPost/screen/boostPostScreen.js | 48 ++++++++++--------- src/screens/promote/screen/promoteScreen.js | 36 +++++++------- 3 files changed, 45 insertions(+), 47 deletions(-) diff --git a/src/containers/pointsContainer.js b/src/containers/pointsContainer.js index 045ef9f7e..57f971396 100644 --- a/src/containers/pointsContainer.js +++ b/src/containers/pointsContainer.js @@ -228,12 +228,8 @@ class PointsContainer extends Component { }) .catch(error => { if (error) { - Alert.alert( - `Fetching data from server failed, please try again or notify us at info@esteem.app \n${error.message.substr( - 0, - 20, - )}`, - ); + this.setState({ isLoading: false }); + dispatch(toastNotification(intl.formatMessage({ id: 'alert.fail' }))); } }); }; diff --git a/src/screens/boostPost/screen/boostPostScreen.js b/src/screens/boostPost/screen/boostPostScreen.js index dd1e03ec8..826e1f9a5 100644 --- a/src/screens/boostPost/screen/boostPostScreen.js +++ b/src/screens/boostPost/screen/boostPostScreen.js @@ -117,12 +117,25 @@ class BoostPostScreen extends PureComponent { const _permlink = get(seperatedPermlink, '[1]'); const amount = 150 + 50 * factor; - if (get(currentAccount, 'local.authType') === 'steemConnect') { + let userFromRealm; + + if (selectedUser) { + userFromRealm = await getUserDataWithUsername(selectedUser); + } + + const user = userFromRealm + ? { + name: selectedUser, + local: userFromRealm[0], + } + : currentAccount; + + if (get(user, 'local.authType') === 'steemConnect') { const json = JSON.stringify({ - user: selectedUser, + user: get(user, 'name'), author: _author, permlink: _permlink, - amount, + amount: `${amount.toFixed(3)} POINT`, }); const uri = `sign/custom-json?authority=active&required_auths=%5B%22${selectedUser}%22%5D&required_posting_auths=%5B%5D&id=esteem_boost&json=${encodeURIComponent( @@ -134,20 +147,7 @@ class BoostPostScreen extends PureComponent { SCPath: uri, }); } else if (boost) { - let userFromRealm; - - if (selectedUser) { - userFromRealm = await getUserDataWithUsername(selectedUser); - } - - const user = userFromRealm - ? { - name: selectedUser, - local: userFromRealm[0], - } - : currentAccount; - - if (amount && _permlink) boost(amount, _permlink, _author, user); + boost(amount, _permlink, _author, user); } }; @@ -262,10 +262,10 @@ class BoostPostScreen extends PureComponent { factor + 4)} + isDisable={!((balance || _balance) / 50 > factor + 4)} onPress={() => this.setState({ - factor: _balance / 50 > factor + 4 ? factor + 1 : factor, + factor: (balance || _balance) / 50 > factor + 4 ? factor + 1 : factor, }) } > @@ -283,9 +283,11 @@ class BoostPostScreen extends PureComponent { 150 && + (!isLoading || isValid) + ) } onPress={() => this.startActionSheet.current.show()} isLoading={isLoading} @@ -307,7 +309,7 @@ class BoostPostScreen extends PureComponent { cancelButtonIndex={1} destructiveButtonIndex={0} onPress={index => { - index === 0 && + if (index === 0) this._boost(boost, currentAccount, getUserDataWithUsername, navigationParams); }} /> diff --git a/src/screens/promote/screen/promoteScreen.js b/src/screens/promote/screen/promoteScreen.js index 99d40b272..d70dda2c8 100644 --- a/src/screens/promote/screen/promoteScreen.js +++ b/src/screens/promote/screen/promoteScreen.js @@ -113,13 +113,26 @@ class PointsScreen extends PureComponent { const fullPermlink = permlink || get(navigationParams, 'permlink'); const seperatedPermlink = fullPermlink.split('/'); - const author = get(seperatedPermlink, '[0]'); + const _author = get(seperatedPermlink, '[0]'); const _permlink = get(seperatedPermlink, '[1]'); - if (get(currentAccount, 'local.authType') === 'steemConnect') { + let userFromRealm; + + if (selectedUser) { + userFromRealm = await getUserDataWithUsername(selectedUser); + } + + const user = userFromRealm + ? { + name: selectedUser, + local: userFromRealm[0], + } + : currentAccount; + + if (get(user, 'local.authType') === 'steemConnect') { const json = JSON.stringify({ - user: selectedUser, - author, + user: get(user, 'name'), + author: _author, permlink: _permlink, duration: day, }); @@ -133,20 +146,7 @@ class PointsScreen extends PureComponent { SCPath: uri, }); } else if (promote) { - let userFromRealm; - - if (selectedUser) { - userFromRealm = await getUserDataWithUsername(selectedUser); - } - - const user = userFromRealm - ? { - name: selectedUser, - local: userFromRealm[0], - } - : currentAccount; - - promote(day, _permlink, author, user); + promote(day, _permlink, _author, user); } };