Skip to content

Commit

Permalink
fix: default to first account as useCurrentStacksAccount returns unde…
Browse files Browse the repository at this point in the history
…fined, ref #5683
  • Loading branch information
pete-watters authored and alter-eggo committed Aug 6, 2024
1 parent 10af7db commit d67d238
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface CurrentAccountAvatar extends CircleProps {
export function CurrentAccountAvatar() {
const stacksAccount = useCurrentStacksAccount();
const { data: name = 'Account' } = useCurrentAccountDisplayName();
if (!stacksAccount) return null;
if (!stacksAccount) return <AccountAvatar index={0} name={name} publicKey="" />;

return (
<AccountAvatar index={stacksAccount.index} name={name} publicKey={stacksAccount.stxPublicKey} />
Expand Down
3 changes: 0 additions & 3 deletions src/app/features/current-account/current-account-name.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Box, BoxProps, styled } from 'leather-styles/jsx';
import { HasChildren } from '@app/common/has-children';
import { useCurrentAccountDisplayName } from '@app/common/hooks/account/use-account-names';
import { truncateString } from '@app/common/utils';
import { useCurrentStacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks';
import { BasicTooltip } from '@app/ui/components/tooltip/basic-tooltip';

function AccountNameTitle({ children, ...props }: HasChildren & BoxProps) {
Expand All @@ -20,9 +19,7 @@ function AccountNameTitle({ children, ...props }: HasChildren & BoxProps) {
}

const AccountNameSuspense = memo((props: BoxProps) => {
const currentAccount = useCurrentStacksAccount();
const { data: name = 'Account' } = useCurrentAccountDisplayName();
if (!currentAccount || typeof currentAccount.index === 'undefined') return null;
// FIXME: The name is truncated here with JS but we could just use CSS to do this
const nameCharLimit = 18;
const isLong = name.length > nameCharLimit;
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/total-balance/total-balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function TotalBalanceSuspense({ displayAddresssBalanceOf }: TotalBalanceProps) {
return (
<TotalBalanceLayout>
<HStack alignItems="center" justifyContent="right">
{account && displayAddresssBalanceOf === 'stx' && <StxBalance address={account.address} />}
{displayAddresssBalanceOf === 'stx' && <StxBalance address={account?.address || ''} />}
{isBitcoinEnabled && displayAddresssBalanceOf === 'all' && <BtcBalance />}
</HStack>
</TotalBalanceLayout>
Expand Down

0 comments on commit d67d238

Please sign in to comment.