Skip to content

Commit

Permalink
Show "-" balance in account selector instead of spinner if total=null
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed May 25, 2023
1 parent 67ffd82 commit d73b616
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const renderComponent = (store: any) =>
<ThemeProvider>
<Account
address="oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe"
balance={1000n.toString()}
balance={{ available: '200', debonding: '0', delegations: '800', total: '1000' }}
type={WalletType.Mnemonic}
onClick={() => {}}
isActive={false}
Expand Down
7 changes: 4 additions & 3 deletions src/app/components/Toolbar/Features/AccountSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ import React, { memo, useContext } from 'react'
import { useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
import { StringifiedBigInt } from 'types/StringifiedBigInt'

Check warning on line 23 in src/app/components/Toolbar/Features/AccountSelector/index.tsx

View workflow job for this annotation

GitHub Actions / build

'StringifiedBigInt' is defined but never used
import { BalanceDetails } from '../../../../state/account/types'

interface Props {
closeHandler: () => any
}

interface AccountProps {
address: string
balance: StringifiedBigInt | null
balance: BalanceDetails | undefined
type: WalletType
onClick: (address: string) => void
path?: number[]
Expand Down Expand Up @@ -91,7 +92,7 @@ export const Account = memo((props: AccountProps) => {
{walletTypes[props.type]} {props.pathDisplay && <Text size="small">({props.pathDisplay})</Text>}
</Box>
<Box height={'24px'}>
{props.balance ? <AmountFormatter amount={props.balance} /> : <Spinner />}
{props.balance ? <AmountFormatter amount={props.balance.total} /> : <Spinner />}
</Box>
</Box>
</Box>
Expand All @@ -115,7 +116,7 @@ export const AccountSelector = memo((props: Props) => {
<Account
key={wallet.address}
address={wallet.address}
balance={wallet.balance?.total}
balance={wallet.balance}
type={wallet.type}
onClick={switchAccount}
isActive={wallet.address === activeAddress}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function ImportAccountsSelector({ accounts }: ImportAccountsSelectorSelectorProp
{accounts.map(a => (
<Account
address={a.address}
balance={a.balance ? a.balance.total : null}
balance={a.balance}
type={a.type}
onClick={toggleAccount}
isActive={a.selected}
Expand Down

0 comments on commit d73b616

Please sign in to comment.