Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show custom token balances even if zero #1422

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/tray/Account/Balances/BalancesPreview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '../../../../../resources/domain/balance'
import { matchFilter } from '../../../../../resources/utils'

import { ClusterBox, Cluster, ClusterRow, ClusterValue } from '../../../../../resources/Components/Cluster'
import { Cluster, ClusterRow, ClusterValue } from '../../../../../resources/Components/Cluster'

import Balance from '../Balance'

Expand Down
5 changes: 4 additions & 1 deletion main/externalData/balances/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ export default function (store: Store) {
function handleTokenBalanceUpdate(balances: TokenBalance[], address: Address) {
// only update balances if any have changed
const currentTokenBalances = storeApi.getTokenBalances(address)
const customTokens = new Set(storeApi.getCustomTokens().map(toTokenId))
const isCustomToken = (balance: Balance) => customTokens.has(toTokenId(balance))

const changedBalances = balances.filter((newBalance) => {
const currentBalance = currentTokenBalances.find(
(b) => b.address === newBalance.address && b.chainId === newBalance.chainId
Expand All @@ -232,7 +235,7 @@ export default function (store: Store) {
const isNewBalance = !currentBalance && parseInt(newBalance.balance) !== 0
const isChangedBalance = !!currentBalance && currentBalance.balance !== newBalance.balance

return isNewBalance || isChangedBalance
return isNewBalance || isChangedBalance || isCustomToken(newBalance)
})

if (changedBalances.length > 0) {
Expand Down