mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-23 13:22:02 +03:00
Merge pull request #1380 from esteemapp/bugfix/walletpage
Wallet bug fixes
This commit is contained in:
commit
c69ccf8f10
Binary file not shown.
@ -16,6 +16,7 @@ import globalStyles from '../../globalStyles';
|
||||
|
||||
const TransactionView = ({ transactions, type, refreshing, setRefreshing, isLoading }) => {
|
||||
const intl = useIntl();
|
||||
const transaction_types = ['ESTM', 'STEEM', 'SBD', 'SP'];
|
||||
|
||||
const _renderLoading = () => {
|
||||
if (isLoading) {
|
||||
@ -44,7 +45,8 @@ const TransactionView = ({ transactions, type, refreshing, setRefreshing, isLoad
|
||||
|
||||
const _renderItem = (item, index) => {
|
||||
return (
|
||||
Object.keys(item).length > 0 && (
|
||||
Object.keys(item).length > 0 &&
|
||||
item.value.indexOf(transaction_types[type]) > -1 && (
|
||||
<CollapsibleCard
|
||||
key={item.created.toString()}
|
||||
noBorder
|
||||
|
@ -19,6 +19,7 @@
|
||||
"outgoing_transfer_title": "Outgoing transfer",
|
||||
"checkin_extra": "Bonus",
|
||||
"delegation": "Delegation",
|
||||
"delegations": "Delegations",
|
||||
"delegation_title": "Delegation reward",
|
||||
"delegation_desc": "Earn ESTM everyday for delegation",
|
||||
"post_title": "Points for post",
|
||||
|
@ -55,6 +55,7 @@ const WalletContainer = ({
|
||||
const [estimatedSpValue, setEstimatedSpValue] = useState(0);
|
||||
const [unclaimedBalance, setUnclaimedBalance] = useState('');
|
||||
const [estimatedAmount, setEstimatedAmount] = useState(0);
|
||||
const [delegationsAmount, setDelegationsAmount] = useState(0);
|
||||
const [transferHistory, setTransferHistory] = useState([]);
|
||||
const intl = useIntl();
|
||||
const dispatch = useDispatch();
|
||||
@ -67,10 +68,6 @@ const WalletContainer = ({
|
||||
_getWalletData(selectedUser);
|
||||
}, [_getWalletData, selectedUser]);
|
||||
|
||||
useEffect(() => {
|
||||
_getWalletData(selectedUser);
|
||||
}, [_getWalletData, selectedUser]);
|
||||
|
||||
useEffect(() => {
|
||||
const _transferHistory = userActivities.filter(
|
||||
item =>
|
||||
@ -106,6 +103,12 @@ const WalletContainer = ({
|
||||
setEstimatedSteemValue(get(walletData, 'estimatedSteemValue', 0));
|
||||
setEstimatedSbdValue(get(walletData, 'estimatedSbdValue', 0));
|
||||
setEstimatedSpValue(get(walletData, 'estimatedSpValue', 0));
|
||||
setDelegationsAmount(
|
||||
vestsToSp(
|
||||
get(walletData, 'vestingSharesReceived', 0) - get(walletData, 'vestingSharesDelegated', 0),
|
||||
get(walletData, 'steemPerMVests', 0),
|
||||
).toFixed(3),
|
||||
);
|
||||
|
||||
setUnclaimedBalance(
|
||||
`${
|
||||
@ -140,9 +143,6 @@ const WalletContainer = ({
|
||||
),
|
||||
);
|
||||
setEstimatedWalletValue && setEstimatedWalletValue(_walletData.estimatedValue);
|
||||
setEstimatedSbdValue && setEstimatedSbdValue(_walletData.estimatedSbdValue);
|
||||
setEstimatedSteemValue && setEstimatedSteemValue(_walletData.estimatedSteemValue);
|
||||
setEstimatedSpValue && setEstimatedSpValue(_walletData.estimatedSpValue);
|
||||
},
|
||||
[globalProps, intl.formatNumber, setEstimatedWalletValue, steemPerMVests],
|
||||
);
|
||||
@ -282,6 +282,7 @@ const WalletContainer = ({
|
||||
estimatedSteemValue,
|
||||
estimatedSbdValue,
|
||||
estimatedSpValue,
|
||||
delegationsAmount,
|
||||
navigate: _navigate,
|
||||
steemDropdown: STEEM_DROPDOWN,
|
||||
sbdDropdown: SBD_DROPDOWN,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { View } from 'react-native';
|
||||
import { View, Text } from 'react-native';
|
||||
|
||||
import { WalletHeader, FormattedCurrency } from '../../../components';
|
||||
import { SteemWalletContainer, AccountContainer } from '../../../containers';
|
||||
@ -20,6 +20,7 @@ const SpView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) =
|
||||
spBalance,
|
||||
isLoading,
|
||||
estimatedSpValue,
|
||||
delegationsAmount,
|
||||
steemPowerDropdown,
|
||||
unclaimedBalance,
|
||||
navigate,
|
||||
@ -45,6 +46,15 @@ const SpView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) =
|
||||
currentIndex={currentIndex}
|
||||
showIconList={false}
|
||||
valueDescriptions={[
|
||||
{
|
||||
textKey: 'delegations',
|
||||
value: (
|
||||
<Text>
|
||||
{delegationsAmount}
|
||||
{' SP'}
|
||||
</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
textKey: 'estimated_value',
|
||||
value: <FormattedCurrency isApproximate isToken value={estimatedSpValue} />,
|
||||
|
@ -100,7 +100,7 @@ const WalletScreen = () => {
|
||||
scrollEventThrottle={16}
|
||||
>
|
||||
<Transaction
|
||||
type="wallet"
|
||||
type={currentIndex}
|
||||
transactions={selectedUserActivities}
|
||||
refreshing={false}
|
||||
setRefreshing={setRefreshing}
|
||||
|
@ -172,25 +172,28 @@ export const groomingWalletData = async (user, globalProps, userCurrency) => {
|
||||
|
||||
const state = await getState(`/@${get(user, 'name')}/transfers`);
|
||||
const { accounts } = state;
|
||||
if (!accounts) {
|
||||
return walletData;
|
||||
}
|
||||
const userdata = get(accounts, get(user, 'name'), '');
|
||||
|
||||
// TODO: move them to utils these so big for a lifecycle function
|
||||
walletData.rewardSteemBalance = parseToken(user.reward_steem_balance);
|
||||
walletData.rewardSbdBalance = parseToken(user.reward_sbd_balance);
|
||||
walletData.rewardVestingSteem = parseToken(user.reward_vesting_steem);
|
||||
walletData.rewardSteemBalance = parseToken(userdata.reward_steem_balance);
|
||||
walletData.rewardSbdBalance = parseToken(userdata.reward_sbd_balance);
|
||||
walletData.rewardVestingSteem = parseToken(userdata.reward_vesting_steem);
|
||||
walletData.hasUnclaimedRewards =
|
||||
walletData.rewardSteemBalance > 0 ||
|
||||
walletData.rewardSbdBalance > 0 ||
|
||||
walletData.rewardVestingSteem > 0;
|
||||
walletData.balance = parseToken(user.balance);
|
||||
walletData.vestingShares = parseToken(user.vesting_shares);
|
||||
walletData.vestingSharesDelegated = parseToken(user.delegated_vesting_shares);
|
||||
walletData.vestingSharesReceived = parseToken(user.received_vesting_shares);
|
||||
walletData.balance = parseToken(userdata.balance);
|
||||
walletData.vestingShares = parseToken(userdata.vesting_shares);
|
||||
walletData.vestingSharesDelegated = parseToken(userdata.delegated_vesting_shares);
|
||||
walletData.vestingSharesReceived = parseToken(userdata.received_vesting_shares);
|
||||
walletData.vestingSharesTotal =
|
||||
walletData.vestingShares - walletData.vestingSharesDelegated + walletData.vestingSharesReceived;
|
||||
|
||||
walletData.sbdBalance = parseToken(user.sbd_balance);
|
||||
walletData.savingBalance = parseToken(user.savings_balance);
|
||||
walletData.savingBalanceSbd = parseToken(user.savings_sbd_balance);
|
||||
walletData.sbdBalance = parseToken(userdata.sbd_balance);
|
||||
walletData.savingBalance = parseToken(userdata.savings_balance);
|
||||
walletData.savingBalanceSbd = parseToken(userdata.savings_sbd_balance);
|
||||
|
||||
const feedHistory = await getFeedHistory();
|
||||
const base = parseToken(feedHistory.current_median_history.base);
|
||||
@ -215,17 +218,14 @@ export const groomingWalletData = async (user, globalProps, userCurrency) => {
|
||||
walletData.estimatedSteemValue = (walletData.balance + walletData.savingBalance) * ppSteem;
|
||||
walletData.estimatedSbdValue = totalSbd * ppSbd;
|
||||
walletData.estimatedSpValue =
|
||||
vestsToSp(walletData.vestingSharesTotal, walletData.steemPerMVests) * ppSteem;
|
||||
vestsToSp(walletData.vestingShares, walletData.steemPerMVests) * ppSteem;
|
||||
|
||||
walletData.showPowerDown = user.next_vesting_withdrawal !== '1969-12-31T23:59:59';
|
||||
const timeDiff = Math.abs(parseDate(user.next_vesting_withdrawal) - new Date());
|
||||
walletData.showPowerDown = userdata.next_vesting_withdrawal !== '1969-12-31T23:59:59';
|
||||
const timeDiff = Math.abs(parseDate(userdata.next_vesting_withdrawal) - new Date());
|
||||
walletData.nextVestingWithdrawal = Math.round(timeDiff / (1000 * 3600));
|
||||
|
||||
const { transfer_history: transferHistory, other_history: virtualHistory } = get(
|
||||
accounts,
|
||||
user.name,
|
||||
[],
|
||||
);
|
||||
const { transfer_history: transferHistory, other_history: virtualHistory } = userdata;
|
||||
|
||||
const realHistory = transferHistory
|
||||
? transferHistory.slice(Math.max(transferHistory.length - 50, 0))
|
||||
: [];
|
||||
|
Loading…
Reference in New Issue
Block a user