1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-22 17:33:23 +01:00

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

This commit is contained in:
Alexander Tseung 2018-03-09 16:31:53 +01:00 committed by GitHub
parent d84341f323
commit ab1b39f554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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