Skip to content

Commit

Permalink
bugfix: Token listed multiple times without account details in Receiv…
Browse files Browse the repository at this point in the history
…e flow
  • Loading branch information
mcayuelas-ledger committed Dec 20, 2024
1 parent a09eb3f commit ab10361
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/stupid-starfishes-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

Fix Token listed multiple times without account details in Receive flow
10 changes: 7 additions & 3 deletions apps/ledger-live-mobile/src/components/AccountCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactNode } from "react";
import { getAccountSpendableBalance } from "@ledgerhq/live-common/account/index";
import { getAccountCurrency } from "@ledgerhq/live-common/account/helpers";
import { getAccountCurrency, getParentAccount } from "@ledgerhq/live-common/account/helpers";
import { getTagDerivationMode } from "@ledgerhq/coin-framework/derivation";
import { AccountLike, Account, DerivationMode } from "@ledgerhq/types-live";
import { Flex, Tag, Text } from "@ledgerhq/native-ui";
Expand All @@ -14,6 +14,8 @@ import CurrencyUnitValue from "./CurrencyUnitValue";
import CounterValue from "./CounterValue";
import { useMaybeAccountName } from "~/reducers/wallet";
import { useMaybeAccountUnit } from "~/hooks/useAccountUnit";
import { useSelector } from "react-redux";
import { accountsSelector } from "~/reducers/accounts";

export type Props = CardProps & {
account?: AccountLike | null;
Expand All @@ -39,9 +41,11 @@ const AccountCard = ({
...props
}: Props) => {
const { colors } = useTheme();
const accounts = useSelector(accountsSelector);

const accountNameFromStore = useMaybeAccountName(account);
const accountName = overridesName || accountNameFromStore;
const parentName = useMaybeAccountName(parentAccount);
const parentName = useMaybeAccountName(account ? getParentAccount(account, accounts) : undefined);
const unit = useMaybeAccountUnit(account);
if (!account || !unit) return null;
const currency = getAccountCurrency(account);
Expand All @@ -53,7 +57,7 @@ const AccountCard = ({
getTagDerivationMode(currency, account.derivationMode as DerivationMode);
const name =
account.type === "TokenAccount"
? parentAccount
? parentName
? `${parentName} (${currency.ticker})`
: currency.ticker
: accountName;
Expand Down

0 comments on commit ab10361

Please sign in to comment.