From e85f65b23ccb64599c235d62ff0db67b32dc3257 Mon Sep 17 00:00:00 2001 From: Theophile Sandoz Date: Fri, 23 Aug 2024 12:07:46 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=B2=20[FEAT]=20Create=20accounts=20wit?= =?UTF-8?q?h=20the=20receive=20market=20quick=20action=20(#7635)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create accounts with the receive market quick action * Update change log --------- Co-authored-by: Theophile Sandoz --- .changeset/tame-carrots-cry.md | 5 +++++ .../src/hooks/useQuickActions.ts | 22 ++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 .changeset/tame-carrots-cry.md diff --git a/.changeset/tame-carrots-cry.md b/.changeset/tame-carrots-cry.md new file mode 100644 index 000000000000..ae0fe75b1fb2 --- /dev/null +++ b/.changeset/tame-carrots-cry.md @@ -0,0 +1,5 @@ +--- +"live-mobile": patch +--- + +Create accounts with the receive market quick action diff --git a/apps/ledger-live-mobile/src/hooks/useQuickActions.ts b/apps/ledger-live-mobile/src/hooks/useQuickActions.ts index 6fe43c162028..1a57a7e99dec 100644 --- a/apps/ledger-live-mobile/src/hooks/useQuickActions.ts +++ b/apps/ledger-live-mobile/src/hooks/useQuickActions.ts @@ -37,8 +37,9 @@ function useQuickActions({ currency, accounts }: QuickActionProps = {}) { const { isCurrencyAvailable } = useRampCatalog(); const readOnlyModeEnabled = useSelector(readOnlyModeEnabledSelector); - const hasAccounts = useSelector(accountsCountSelector) > 0; - const hasFunds = !useSelector(areAccountsEmptySelector) && hasAccounts; + const hasAnyAccounts = useSelector(accountsCountSelector) > 0; + const hasCurrencyAccounts = currency ? !!accounts?.length : hasAnyAccounts; + const hasFunds = !useSelector(areAccountsEmptySelector) && hasAnyAccounts; const hasCurrency = currency ? !!accounts?.some(({ balance }) => balance.gt(0)) : hasFunds; const recoverEntryPoint = useFeature("protectServicesMobile"); @@ -70,12 +71,16 @@ function useQuickActions({ currency, accounts }: QuickActionProps = {}) { disabled: readOnlyModeEnabled, route: [ NavigatorName.ReceiveFunds, - currency - ? { - screen: ScreenName.ReceiveSelectAccount, - params: { currency }, - } - : { screen: ScreenName.ReceiveSelectCrypto }, + !currency + ? { screen: ScreenName.ReceiveSelectCrypto } + : { + screen: hasCurrencyAccounts + ? ScreenName.ReceiveSelectAccount + : ScreenName.ReceiveAddAccountSelectDevice, + params: { + currency: currency.type === "TokenCurrency" ? currency.parentCurrency : currency, + }, + }, ], icon: IconsLegacy.ArrowBottomMedium, }, @@ -166,6 +171,7 @@ function useQuickActions({ currency, accounts }: QuickActionProps = {}) { return list; }, [ currency, + hasCurrencyAccounts, hasCurrency, hasFunds, isPtxServiceCtaExchangeDrawerDisabled,