From 751b4f2a976ee7729a3a00196fc6f2adcfb344f8 Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Fri, 20 Dec 2019 11:11:15 -0500 Subject: [PATCH] remove duplicates from currency select --- src/components/base/CurrencySelect.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/base/CurrencySelect.jsx b/src/components/base/CurrencySelect.jsx index fe8e07f..fc57b47 100644 --- a/src/components/base/CurrencySelect.jsx +++ b/src/components/base/CurrencySelect.jsx @@ -4,6 +4,7 @@ import TextField from '@material-ui/core/TextField' import MenuItem from '@material-ui/core/MenuItem' import FormControlLabel from '@material-ui/core/FormControlLabel' import Switch from '@material-ui/core/Switch' +import { uniqBy, filter, isNil, compose } from 'ramda' import { NEW_TOKEN_ICON_API } from '../../utils/currencies' import { toEther } from '../../utils/conversions' import { checksumAddress } from '../../utils/address' @@ -28,7 +29,10 @@ const orderCurrencies = (currencies, balances, publishing) => { const temp = [...currencies] let weth = currencies.findIndex(e => e.label === 'WETH') temp[0] = temp[weth] - return temp.filter(e => e !== undefined) + const dedupe = uniqBy(e => e.value) + const removeNils = filter(e => !isNil(e)) + const process = compose(removeNils, dedupe) + return process(temp) } return balances ? currencies.filter(c => c.label === 'ETH' || (balances[c.value] && !balances[c.value].isZero())) : currencies }