Remove de-selected token from selectedTokens hash instead of setting to null (#3494)

feature/default_network_editable
Alexander Tseung 7 years ago committed by GitHub
parent d84341f323
commit ab1b39f554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      ui/app/add-token.js

@ -71,13 +71,17 @@ AddTokenScreen.prototype.componentWillMount = function () {
} }
AddTokenScreen.prototype.toggleToken = function (address, token) { AddTokenScreen.prototype.toggleToken = function (address, token) {
const { selectedTokens, errors } = this.state const { selectedTokens = {}, errors } = this.state
const { [address]: selectedToken } = selectedTokens const selectedTokensCopy = { ...selectedTokens }
if (address in selectedTokensCopy) {
delete selectedTokensCopy[address]
} else {
selectedTokensCopy[address] = token
}
this.setState({ this.setState({
selectedTokens: { selectedTokens: selectedTokensCopy,
...selectedTokens,
[address]: selectedToken ? null : token,
},
errors: { errors: {
...errors, ...errors,
tokenSelector: null, tokenSelector: null,

Loading…
Cancel
Save