Skip to content

Commit

Permalink
fix: Hide asset in wallet explanation if none are in wallet (#2927)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbuedo authored Dec 1, 2023
1 parent a175b17 commit 57e5ef3
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ const TokenList = () => {
return onlyVerifiedTokens
}, [onlyVerifiedTokens])

const filteredTokenList = React.useMemo(() => {
const filter = filterBySearch(assetSearchTerm)
return tokenInfos.filter((tokenInfo) => filter(tokenInfo)).sort((a, b) => sortTokensByName(a, b, wallet))
}, [tokenInfos, assetSearchTerm, wallet])
const [filteredTokenList, someInWallet] = React.useMemo(() => {
const list = tokenInfos.filter(filterBySearch(assetSearchTerm)).sort((a, b) => sortTokensByName(a, b, wallet))
const set = new Set(list.map(({id}) => id))
const someInWallet = walletTokenIds.some((id) => set.has(id))
return [list, someInWallet]
}, [tokenInfos, assetSearchTerm, walletTokenIds, wallet])

return (
<View style={styles.list}>
Expand Down Expand Up @@ -113,13 +115,15 @@ const TokenList = () => {

<Spacer height={16} />

<View style={[styles.row, styles.ph]}>
<Icon.Portfolio size={20} color={COLORS.LIGHT_GREEN} />
{someInWallet && (
<View style={[styles.row, styles.ph]}>
<Icon.Portfolio size={20} color={COLORS.LIGHT_GREEN} />

<Spacer width={8} />
<Spacer width={8} />

<Text style={styles.legend}>{strings.assetsIn}</Text>
</View>
<Text style={styles.legend}>{strings.assetsIn}</Text>
</View>
)}

<Counter
counter={filteredTokenList.length}
Expand Down

0 comments on commit 57e5ef3

Please sign in to comment.