Skip to content

Commit

Permalink
chore: add tokenId check when removing asset from visible assets list
Browse files Browse the repository at this point in the history
  • Loading branch information
muliswilliam committed Jul 21, 2022
1 parent f951b1d commit 440134d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ const AssetWatchlistItem = (props: Props) => {
<DeleteIcon />
</DeleteButton>
}
<Checkbox value={{ [`${token.contractAddress}-${token.symbol}-${token.chainId}`]: isSelected }} onChange={onCheck}>
<div data-key={`${token.contractAddress}-${token.symbol}-${token.chainId}`} />
<Checkbox value={{ [`${token.contractAddress}-${token.symbol}-${token.chainId}-${token.tokenId}`]: isSelected }} onChange={onCheck}>
<div data-key={`${token.contractAddress}-${token.symbol}-${token.chainId}-${token.tokenId}`} />
</Checkbox>
</RightSide>
</StyledWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ const EditVisibleAssetsModal = ({ onClose }: Props) => {
return updatedTokensList.find((t) =>
t.symbol.toLowerCase() === token.symbol.toLowerCase() &&
t.contractAddress.toLowerCase() === token.contractAddress.toLowerCase() &&
t.chainId === token.chainId)
t.chainId === token.chainId &&
t.tokenId === token.tokenId)
}

const isUserToken = (token: BraveWallet.BlockchainToken) => {
Expand Down Expand Up @@ -333,7 +334,8 @@ const EditVisibleAssetsModal = ({ onClose }: Props) => {
const tokenIndex = updatedTokensList.findIndex((t) =>
t.contractAddress.toLowerCase() === token.contractAddress.toLowerCase() &&
t.symbol.toLowerCase() === token.symbol.toLowerCase() &&
t.chainId === token.chainId)
t.chainId === token.chainId &&
t.tokenId === token.tokenId)
let newList = [...updatedTokensList]
newList.splice(tokenIndex, 1, updatedToken)
setUpdatedTokensList(newList)
Expand Down Expand Up @@ -366,9 +368,9 @@ const EditVisibleAssetsModal = ({ onClose }: Props) => {
}

const onRemoveAsset = (token: BraveWallet.BlockchainToken) => {
const newUserList = updatedTokensList.filter((t) => t.contractAddress.toLowerCase() !== token.contractAddress.toLowerCase())
const newUserList = updatedTokensList.filter((t) => t.contractAddress.toLowerCase() !== token.contractAddress.toLowerCase() && t.tokenId === token.tokenId)
setUpdatedTokensList(newUserList)
const newFilteredTokenList = filteredTokenList.filter((t) => t.contractAddress.toLowerCase() !== token.contractAddress.toLowerCase())
const newFilteredTokenList = filteredTokenList.filter((t) => t.contractAddress.toLowerCase() !== token.contractAddress.toLowerCase() && t.tokenId === token.tokenId)
setFilteredTokenList(newFilteredTokenList)
}

Expand Down

0 comments on commit 440134d

Please sign in to comment.