Skip to content

Commit

Permalink
fix: white screen on account select list
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Oct 20, 2022
1 parent 9042a98 commit 82ec23c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
20 changes: 3 additions & 17 deletions src/app/components/account/account-balance-caption.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import { useMemo } from 'react';
import { color } from '@stacks/ui';

import { microStxToStx, stacksValue } from '@app/common/stacks-utils';
import { stacksValue } from '@app/common/stacks-utils';
import { Caption, Text } from '@app/components/typography';
import { baseCurrencyAmountInQuote } from '@app/common/money/calculate-money';
import { createMoney, i18nFormatCurrency, Money } from '@shared/models/money.model';
import { MarketData } from '@shared/models/market.model';
import { Money } from '@shared/models/money.model';

interface AccountBalanceCaptionProps {
availableBalance: Money;
marketData: MarketData;
}
export function AccountBalanceCaption({
availableBalance,
marketData,
}: AccountBalanceCaptionProps) {
export function AccountBalanceCaption({ availableBalance }: AccountBalanceCaptionProps) {
const balance = useMemo(
() =>
stacksValue({
Expand All @@ -36,14 +30,6 @@ export function AccountBalanceCaption({
<Text color={color('text-caption')} fontSize="10px">
</Text>
<Caption>
{i18nFormatCurrency(
baseCurrencyAmountInQuote(
createMoney(microStxToStx(availableBalance.amount), 'STX'),
marketData
)
)}
</Caption>
</>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,14 @@ import { AccountListItemLayout } from '../../../components/account/account-list-
import { AccountAvatarItem } from './account-avatar';
import { AccountWithAddress } from '@app/store/accounts/account.models';
import { usePressable } from '@app/components/item-hover';
import { useStxMarketData } from '@app/query/common/market-data/market-data.hooks';

interface AccountBalanceLabelProps {
address: string;
}
const AccountBalanceLabel = memo(({ address }: AccountBalanceLabelProps) => {
const { data: balances } = useAddressBalances(address);
const stxMarketData = useStxMarketData();

if (!balances) return null;

return (
<AccountBalanceCaption availableBalance={balances.availableStx} marketData={stxMarketData} />
);
return <AccountBalanceCaption availableBalance={balances.availableStx} />;
});

interface SwitchAccountListItemProps {
Expand Down
8 changes: 2 additions & 6 deletions src/app/pages/choose-account/components/accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { AccountWithAddress } from '@app/store/accounts/account.models';
import { useNavigate } from 'react-router-dom';
import { RouteUrls } from '@shared/route-urls';
import { AccountListItemLayout } from '@app/components/account/account-list-item-layout';
import { useStxMarketData } from '@app/query/common/market-data/market-data.hooks';

const loadingProps = { color: '#A1A7B3' };
const getLoadingProps = (loading: boolean) => (loading ? loadingProps : {});
Expand Down Expand Up @@ -64,7 +63,7 @@ const ChooseAccountItem = memo((props: ChooseAccountItemProps) => {
const { decodedAuthRequest } = useOnboardingState();
const name = useAccountDisplayName(account);
const { data: balances, isLoading: isBalanceLoading } = useAddressBalances(account.address);
const fiatValue = useStxMarketData();

const showLoadingProps = !!selectedAddress || !decodedAuthRequest;

const accountSlug = useMemo(() => slugify(`Account ${account?.index + 1}`), [account?.index]);
Expand All @@ -89,10 +88,7 @@ const ChooseAccountItem = memo((props: ChooseAccountItemProps) => {
isBalanceLoading ? (
<AccountBalanceLoading />
) : balances ? (
<AccountBalanceCaption
availableBalance={balances.availableStx}
marketData={fiatValue}
/>
<AccountBalanceCaption availableBalance={balances.availableStx} />
) : (
<></>
)
Expand Down

0 comments on commit 82ec23c

Please sign in to comment.