mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-03 11:40:44 +03:00
fix currency change values
This commit is contained in:
parent
3e5d1c07ab
commit
115e5f1b57
@ -1,3 +1,3 @@
|
||||
import FormatedCurrency from './formattedCurrency/formattedCurrencyView';
|
||||
import FormattedCurrency from './formattedCurrency/formattedCurrencyView';
|
||||
|
||||
export { FormatedCurrency };
|
||||
export { FormattedCurrency };
|
||||
|
@ -9,7 +9,7 @@ import { ContainerHeader } from './containerHeader';
|
||||
import { DateTimePicker } from './dateTimePicker';
|
||||
import { DropdownButton } from './dropdownButton';
|
||||
import { FilterBar } from './filterBar';
|
||||
import { FormatedCurrency } from './formatedElements';
|
||||
import { FormattedCurrency } from './formatedElements';
|
||||
import { FormInput } from './formInput';
|
||||
import { Header } from './header';
|
||||
import { Icon } from './icon';
|
||||
@ -112,7 +112,7 @@ export {
|
||||
DateTimePicker,
|
||||
DropdownButton,
|
||||
FilterBar,
|
||||
FormatedCurrency,
|
||||
FormattedCurrency,
|
||||
FormInput,
|
||||
GrayWrapper,
|
||||
Header,
|
||||
|
@ -58,7 +58,6 @@ class LeaderboardContainer extends PureComponent {
|
||||
}
|
||||
let users;
|
||||
|
||||
console.log(index);
|
||||
if (!isConnected) {
|
||||
return;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import { getEstimatedAmount } from '../../../utils/vote';
|
||||
import { Icon } from '../../icon';
|
||||
import { PulseAnimation } from '../../animations';
|
||||
import { TextButton } from '../../buttons';
|
||||
import { FormatedCurrency } from '../../formatedElements';
|
||||
import { FormattedCurrency } from '../../formatedElements';
|
||||
|
||||
// STEEM
|
||||
import { vote } from '../../../providers/steem/dsteem';
|
||||
@ -259,7 +259,7 @@ class UpvoteView extends Component {
|
||||
<TextButton
|
||||
style={styles.payoutTextButton}
|
||||
textStyle={[styles.payoutValue, isDecinedPayout && styles.declinedPayout]}
|
||||
text={<FormatedCurrency value={_totalPayout} />}
|
||||
text={<FormattedCurrency value={_totalPayout} />}
|
||||
onPress={() => {
|
||||
openPopover();
|
||||
this.setState({ isShowDetails: true });
|
||||
|
@ -121,6 +121,9 @@ const WalletContainer = ({
|
||||
),
|
||||
);
|
||||
setEstimatedWalletValue && setEstimatedWalletValue(_walletData.estimatedValue);
|
||||
setEstimatedSbdValue && setEstimatedSbdValue(_walletData.estimatedSbdValue);
|
||||
setEstimatedSteemValue && setEstimatedSteemValue(_walletData.estimatedSteemValue);
|
||||
setEstimatedSpValue && setEstimatedSpValue(_walletData.estimatedSpValue);
|
||||
},
|
||||
[globalProps, intl.formatNumber, setEstimatedWalletValue, steemPerMVests],
|
||||
);
|
||||
|
@ -5,12 +5,16 @@ import serverList from '../../config/serverListApi';
|
||||
import { jsonStringify } from '../../utils/jsonUtils';
|
||||
import bugsnag from '../../config/bugsnag';
|
||||
// market-data/currency-rate/USD/estm
|
||||
|
||||
// SBD=$1 for post values
|
||||
export const getCurrencyRate = currency =>
|
||||
api
|
||||
.get(`/market-data/currency-rate/${currency.toUpperCase()}/steem`)
|
||||
.get(`/market-data/currency-rate/${currency.toUpperCase()}/sbd?fixed=1`)
|
||||
.then(resp => resp.data)
|
||||
.catch(err => {
|
||||
console.log('err :', err);
|
||||
//TODO: save currency rate of offline values
|
||||
return 1;
|
||||
});
|
||||
|
||||
export const getCurrencyTokenRate = (currency, token) =>
|
||||
|
@ -410,7 +410,6 @@ export const setNotificationSettings = async ({ type, action }) => {
|
||||
export const setCurrency = async currencyProps => {
|
||||
try {
|
||||
const setting = await getItemFromStorage(SETTINGS_SCHEMA);
|
||||
|
||||
setting.currency = currencyProps;
|
||||
await setItemToStorage(SETTINGS_SCHEMA, setting);
|
||||
|
||||
@ -420,6 +419,18 @@ export const setCurrency = async currencyProps => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getCurrency = async () => {
|
||||
try {
|
||||
const setting = await getItemFromStorage(SETTINGS_SCHEMA);
|
||||
if (setting) {
|
||||
return setting.currency;
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
};
|
||||
|
||||
export const getLanguage = async () => {
|
||||
try {
|
||||
const setting = await getItemFromStorage(SETTINGS_SCHEMA);
|
||||
|
@ -485,7 +485,7 @@ class ApplicationContainer extends Component {
|
||||
}
|
||||
if (settings.nsfw !== '') dispatch(setNsfw(settings.nsfw));
|
||||
|
||||
if (isConnected) {
|
||||
if (settings.currency !== '') {
|
||||
dispatch(setCurrency(settings.currency !== '' ? settings.currency : 'usd'));
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { View } from 'react-native';
|
||||
|
||||
import { WalletHeader, FormatedCurrency } from '../../../components';
|
||||
import { WalletHeader, FormattedCurrency } from '../../../components';
|
||||
import { SteemWalletContainer, AccountContainer } from '../../../containers';
|
||||
|
||||
import globalStyles from '../../../globalStyles';
|
||||
@ -45,7 +45,7 @@ const SbdView = ({ handleOnSelected, index, currentIndex }) => (
|
||||
valueDescriptions={[
|
||||
{
|
||||
textKey: 'estimated_value',
|
||||
value: <FormatedCurrency isApproximate value={estimatedSbdValue} />,
|
||||
value: <FormattedCurrency isApproximate value={estimatedSbdValue} />,
|
||||
subTextKey: 'estimated_value_desc',
|
||||
},
|
||||
]}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { View } from 'react-native';
|
||||
|
||||
import { WalletHeader, FormatedCurrency } from '../../../components';
|
||||
import { WalletHeader, FormattedCurrency } from '../../../components';
|
||||
import { SteemWalletContainer, AccountContainer } from '../../../containers';
|
||||
|
||||
import globalStyles from '../../../globalStyles';
|
||||
@ -46,11 +46,11 @@ const SpView = ({ handleOnSelected, index, currentIndex }) => (
|
||||
valueDescriptions={[
|
||||
{
|
||||
textKey: 'estimated_value',
|
||||
value: <FormatedCurrency isApproximate value={estimatedSpValue} />,
|
||||
value: <FormattedCurrency isApproximate value={estimatedSpValue} />,
|
||||
},
|
||||
{
|
||||
textKey: 'estimated_amount',
|
||||
value: <FormatedCurrency isApproximate value={estimatedAmount} />,
|
||||
value: <FormattedCurrency isApproximate value={estimatedAmount} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { View } from 'react-native';
|
||||
|
||||
import { WalletHeader, FormatedCurrency } from '../../../components';
|
||||
import { WalletHeader, FormattedCurrency } from '../../../components';
|
||||
import { SteemWalletContainer, AccountContainer } from '../../../containers';
|
||||
|
||||
import globalStyles from '../../../globalStyles';
|
||||
@ -49,7 +49,7 @@ const SteemView = ({ handleOnSelected, index, currentIndex }) => (
|
||||
valueDescriptions={[
|
||||
{
|
||||
textKey: 'estimated_value',
|
||||
value: <FormatedCurrency isApproximate value={estimatedSteemValue} />,
|
||||
value: <FormattedCurrency isApproximate value={estimatedSteemValue} />,
|
||||
subTextKey: 'estimated_value_desc',
|
||||
},
|
||||
]}
|
||||
|
@ -4,6 +4,7 @@ import parseToken from './parseToken';
|
||||
import { vestsToSp } from './conversions';
|
||||
import { getState, getFeedHistory } from '../providers/steem/dsteem';
|
||||
import { getCurrencyTokenRate } from '../providers/esteem/esteem';
|
||||
import { getCurrency } from '../realm/realm';
|
||||
|
||||
export const groomingTransactionData = (transaction, steemPerMVests, formatNumber) => {
|
||||
if (!transaction || !steemPerMVests) {
|
||||
@ -156,9 +157,10 @@ export const groomingWalletData = async (user, globalProps) => {
|
||||
const totalSbd = walletData.sbdBalance + walletData.savingBalanceSbd;
|
||||
|
||||
walletData.estimatedValue = totalSteem * pricePerSteem + totalSbd;
|
||||
const userCurrency = await getCurrency();
|
||||
|
||||
const ppSbd = await getCurrencyTokenRate('usd', 'sbd');
|
||||
const ppSteem = await getCurrencyTokenRate('usd', 'steem');
|
||||
const ppSbd = await getCurrencyTokenRate(userCurrency, 'sbd');
|
||||
const ppSteem = await getCurrencyTokenRate(userCurrency, 'steem');
|
||||
|
||||
walletData.estimatedSteemValue = (walletData.balance + walletData.savingBalance) * ppSteem;
|
||||
walletData.estimatedSbdValue = totalSbd * ppSbd;
|
||||
|
Loading…
Reference in New Issue
Block a user