Merge pull request #537 from esteemapp/claim-bug

Claim bug
This commit is contained in:
uğur erdal 2019-02-06 18:24:27 +03:00 committed by GitHub
commit d5c1368120
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ import { getAccount, claimRewardBalance } from '../../../providers/steem/dsteem'
// Utils
import { groomingWalletData } from '../../../utils/wallet';
import parseToken from '../../../utils/parseToken';
// Component
import WalletView from '../view/walletView';
@ -55,11 +56,16 @@ class WalletContainer extends Component {
setEstimatedWalletValue(walletData.estimatedValue);
};
_isHasUnclaimedRewards = account => parseToken(account.reward_steem_balance) > 0
|| parseToken(account.reward_sbd_balance) > 0
|| parseToken(account.reward_vesting_steem) > 0;
_claimRewardBalance = async () => {
const {
currentAccount, intl, pinCode, dispatch,
} = this.props;
const { isClaiming } = this.state;
let isHasUnclaimedRewards;
if (isClaiming) {
return;
@ -69,25 +75,29 @@ class WalletContainer extends Component {
getAccount(currentAccount.name)
.then((account) => {
const {
reward_steem_balance: steemBal,
reward_sbd_balance: sbdBal,
reward_vesting_balance: vestingBal,
} = account[0];
return claimRewardBalance(currentAccount, pinCode, steemBal, sbdBal, vestingBal);
isHasUnclaimedRewards = this._isHasUnclaimedRewards(account[0]);
if (isHasUnclaimedRewards) {
const {
reward_steem_balance: steemBal,
reward_sbd_balance: sbdBal,
reward_vesting_balance: vestingBal,
} = account[0];
return claimRewardBalance(currentAccount, pinCode, steemBal, sbdBal, vestingBal);
}
this.setState({ isClaiming: false });
})
.then(() => getAccount(currentAccount.name))
.then((account) => {
this._getWalletData(account && account[0]);
dispatch(
toastNotification(
intl.formatMessage({
id: 'alert.claim_reward_balance_ok',
}),
),
);
if (isHasUnclaimedRewards) {
dispatch(
toastNotification(
intl.formatMessage({
id: 'alert.claim_reward_balance_ok',
}),
),
);
}
})
.then((account) => {
this._getWalletData(account && account[0]);