mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-02 11:15:35 +03:00
commit
d5c1368120
@ -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]);
|
||||
|
Loading…
Reference in New Issue
Block a user