From 3d53716f4366212ed7a51b49ce747584b13fd1ce Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Fri, 27 Oct 2017 03:25:34 -0230 Subject: Correct rendering of conversions when conversion rate is a token. (#2498) --- ui/app/components/token-cell.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'ui/app/components/token-cell.js') diff --git a/ui/app/components/token-cell.js b/ui/app/components/token-cell.js index 6bb42204e..f55e23f9e 100644 --- a/ui/app/components/token-cell.js +++ b/ui/app/components/token-cell.js @@ -6,7 +6,7 @@ const Identicon = require('./identicon') const prefixForNetwork = require('../../lib/etherscan-prefix-for-network') const selectors = require('../selectors') const actions = require('../actions') -const { conversionUtil } = require('../conversion-util') +const { conversionUtil, multiplyCurrencies } = require('../conversion-util') const TokenMenuDropdown = require('./dropdowns/token-menu-dropdown.js') @@ -17,7 +17,7 @@ function mapStateToProps (state) { selectedTokenAddress: state.metamask.selectedTokenAddress, userAddress: selectors.getSelectedAddress(state), tokenExchangeRates: state.metamask.tokenExchangeRates, - ethToUSDRate: state.metamask.conversionRate, + conversionRate: state.metamask.conversionRate, sidebarOpen: state.appState.sidebarOpen, } } @@ -61,7 +61,7 @@ TokenCell.prototype.render = function () { setSelectedToken, selectedTokenAddress, tokenExchangeRates, - ethToUSDRate, + conversionRate, hideSidebar, sidebarOpen, currentCurrency, @@ -70,22 +70,26 @@ TokenCell.prototype.render = function () { const pair = `${symbol.toLowerCase()}_eth`; - let currentTokenToEthRate; + let currentTokenToFiatRate; let currentTokenInFiat; - let formattedUSD = '' + let formattedFiat = '' if (tokenExchangeRates[pair]) { - currentTokenToEthRate = tokenExchangeRates[pair].rate; + currentTokenToFiatRate = multiplyCurrencies( + tokenExchangeRates[pair].rate, + conversionRate + ) currentTokenInFiat = conversionUtil(string, { fromNumericBase: 'dec', fromCurrency: symbol, - toCurrency: 'USD', + toCurrency: currentCurrency.toUpperCase(), numberOfDecimals: 2, - conversionRate: currentTokenToEthRate, - ethToUSDRate, + conversionRate: currentTokenToFiatRate, }) - formattedUSD = `${currentTokenInFiat} ${currentCurrency.toUpperCase()}`; + formattedFiat = `${currentTokenInFiat} ${currentCurrency.toUpperCase()}`; } + + const showFiat = Boolean(currentTokenInFiat) && currentCurrency.toUpperCase() !== symbol return ( h('div.token-list-item', { @@ -108,9 +112,9 @@ TokenCell.prototype.render = function () { h('h.token-list-item__balance-wrapper', null, [ h('h3.token-list-item__token-balance', `${string || 0} ${symbol}`), - h('div.token-list-item__fiat-amount', { + showFiat && h('div.token-list-item__fiat-amount', { style: {}, - }, formattedUSD), + }, formattedFiat), ]), h('i.fa.fa-ellipsis-h.fa-lg.token-list-item__ellipsis.cursor-pointer', { -- cgit v1.2.3 From 56e9f98bd05de8ae26f653d15eec4304f0c72155 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 2 Nov 2017 09:45:59 -0230 Subject: More lint fixes --- ui/app/components/token-cell.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ui/app/components/token-cell.js') diff --git a/ui/app/components/token-cell.js b/ui/app/components/token-cell.js index f55e23f9e..b40c0ec0d 100644 --- a/ui/app/components/token-cell.js +++ b/ui/app/components/token-cell.js @@ -67,11 +67,11 @@ TokenCell.prototype.render = function () { currentCurrency, // userAddress, } = props - - const pair = `${symbol.toLowerCase()}_eth`; - let currentTokenToFiatRate; - let currentTokenInFiat; + const pair = `${symbol.toLowerCase()}_eth` + + let currentTokenToFiatRate + let currentTokenInFiat let formattedFiat = '' if (tokenExchangeRates[pair]) { @@ -86,11 +86,11 @@ TokenCell.prototype.render = function () { numberOfDecimals: 2, conversionRate: currentTokenToFiatRate, }) - formattedFiat = `${currentTokenInFiat} ${currentCurrency.toUpperCase()}`; + formattedFiat = `${currentTokenInFiat} ${currentCurrency.toUpperCase()}` } const showFiat = Boolean(currentTokenInFiat) && currentCurrency.toUpperCase() !== symbol - + return ( h('div.token-list-item', { className: `token-list-item ${selectedTokenAddress === address ? 'token-list-item--active' : ''}`, -- cgit v1.2.3