Skip to content

Commit

Permalink
Revert "chore: add tokenId check when removing asset from visible ass…
Browse files Browse the repository at this point in the history
…ets list"

This reverts commit 440134d. This will be fixed in brave/brave-browser#24238
  • Loading branch information
muliswilliam committed Jul 25, 2022
1 parent 22f7077 commit 422db96
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 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}-${token.tokenId}`]: isSelected }} onChange={onCheck}>
<div data-key={`${token.contractAddress}-${token.symbol}-${token.chainId}-${token.tokenId}`} />
<Checkbox value={{ [`${token.contractAddress}-${token.symbol}-${token.chainId}`]: isSelected }} onChange={onCheck}>
<div data-key={`${token.contractAddress}-${token.symbol}-${token.chainId}`} />
</Checkbox>
</RightSide>
</StyledWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ 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.tokenId === token.tokenId)
t.chainId === token.chainId)
}

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const PortfolioAsset = () => {
const history = useHistory()
const { id: assetId, tokenId } = useParams<{ id?: string, tokenId?: string }>()
const nftDetailsRef = React.useRef<HTMLIFrameElement>(null)
const [nftIframeLoaded, setNftIframeLoaded] = React.useState(false)
// redux
const dispatch = useDispatch()
const {
Expand Down Expand Up @@ -315,6 +316,8 @@ export const PortfolioAsset = () => {
}, [nftDetailsRef, isFetchingNFTMetadata])

React.useEffect(() => {
if (!nftIframeLoaded) return

if (selectedAsset && nftDetailsRef?.current) {
const command: UpdateSelectedAssetMessage = {
command: NftUiCommand.UpdateSelectedAsset,
Expand All @@ -339,7 +342,7 @@ export const PortfolioAsset = () => {
}
sendMessageToNftUiFrame(nftDetailsRef.current.contentWindow, command)
}
}, [nftDetailsRef, selectedAsset, nftMetadata, networkList])
}, [nftIframeLoaded, nftDetailsRef, selectedAsset, nftMetadata, networkList])

// token list needs to load before we can find an asset to select from the url params
if (userVisibleTokensInfo.length === 0) {
Expand Down Expand Up @@ -420,6 +423,7 @@ export const PortfolioAsset = () => {
}

<NftDetails
onLoad={() => setNftIframeLoaded(true)}
visible={selectedAsset?.isErc721}
ref={nftDetailsRef}
sandbox="allow-scripts allow-popups allow-same-origin"
Expand Down

0 comments on commit 422db96

Please sign in to comment.