1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-24 01:08:27 +00:00

Merge pull request #74 from satoshilabs/fix-multiple-same-tokens

fix: disallow adding multiple tokens of same type in AccountSummary
This commit is contained in:
Vladimir Volek 2018-09-21 14:12:41 +02:00 committed by GitHub
commit 1c2a4fb3f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -131,7 +131,12 @@ const AccountSummary = (props: Props) => {
placeholder="Search for the token" placeholder="Search for the token"
loadingMessage={() => 'Loading...'} loadingMessage={() => 'Loading...'}
noOptionsMessage={() => 'Token not found'} noOptionsMessage={() => 'Token not found'}
onChange={token => props.addToken(token, account)} onChange={(token) => {
const isAdded = tokens.find(t => t.symbol === token.symbol);
if (!isAdded) {
props.addToken(token, account);
}
}}
loadOptions={input => props.loadTokens(input, account.network)} loadOptions={input => props.loadTokens(input, account.network)}
formatOptionLabel={(option) => { formatOptionLabel={(option) => {
const isAdded = tokens.find(t => t.symbol === option.symbol); const isAdded = tokens.find(t => t.symbol === option.symbol);