From 03c90eebebd87cb58c796fd422657b8a0ace8ab3 Mon Sep 17 00:00:00 2001 From: LFBarreto Date: Fri, 5 Aug 2022 11:04:44 +0200 Subject: [PATCH 1/2] LIVE-3222 - LLM - Receive flow fix multiple accounts selected issue --- .changeset/shiny-pumpkins-explain.md | 5 +++ .../screens/ReceiveFunds/02-AddAccount.tsx | 28 +++++++++------- .../screens/ReceiveFunds/02-SelectAccount.tsx | 32 ++++++++++++------- 3 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 .changeset/shiny-pumpkins-explain.md diff --git a/.changeset/shiny-pumpkins-explain.md b/.changeset/shiny-pumpkins-explain.md new file mode 100644 index 000000000000..74b38d3d3ba7 --- /dev/null +++ b/.changeset/shiny-pumpkins-explain.md @@ -0,0 +1,5 @@ +--- +"live-mobile": patch +--- + +LLM - Receive flow prevent creation of multiple accounts at the same time diff --git a/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccount.tsx b/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccount.tsx index 2c3dd8a7f689..835bf29b6d52 100644 --- a/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccount.tsx +++ b/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccount.tsx @@ -51,6 +51,7 @@ function AddAccountsAccounts({ navigation, route }: Props) { const [error, setError] = useState(null); const [scannedAccounts, setScannedAccounts] = useState([]); const [cancelled, setCancelled] = useState(false); + const [selectedAccount, setSelectedAccount] = useState(null); const scanSubscription = useRef(); @@ -143,19 +144,22 @@ function AddAccountsAccounts({ navigation, route }: Props) { const selectAccount = useCallback( (account: Account) => { - dispatch( - replaceAccounts({ - scannedAccounts, - selectedIds: [account.id], - renamings: {}, - }), - ); - navigation.navigate(ScreenName.ReceiveConfirmation, { - ...route.params, - accountId: account.id, - }); + if (!selectedAccount) { + setSelectedAccount(account.id); + dispatch( + replaceAccounts({ + scannedAccounts, + selectedIds: [account.id], + renamings: {}, + }), + ); + navigation.navigate(ScreenName.ReceiveConfirmation, { + ...route.params, + accountId: account.id, + }); + } }, - [dispatch, navigation, route.params, scannedAccounts], + [dispatch, navigation, route.params, scannedAccounts, selectedAccount], ); const renderItem = useCallback( diff --git a/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-SelectAccount.tsx b/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-SelectAccount.tsx index e63123ccebe8..be93fb84060f 100644 --- a/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-SelectAccount.tsx +++ b/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-SelectAccount.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useMemo } from "react"; +import React, { useCallback, useMemo, useState } from "react"; import { FlatList } from "react-native"; import { useSelector } from "react-redux"; @@ -24,6 +24,7 @@ function ReceiveSelectAccount({ navigation, route }: Props) { const currency = route.params?.currency; const routerRoute = useRoute(); const { t } = useTranslation(); + const [selectedAccount, setSelectedAccount] = useState(null); const accounts = useSelector( flattenAccountsByCryptoCurrencyScreenSelector(currency), @@ -57,17 +58,26 @@ function ReceiveSelectAccount({ navigation, route }: Props) { const selectAccount = useCallback( (account: AccountLike) => { - track("account_clicked", { - currency: currency.name, - screen: routerRoute.name, - }); - navigation.navigate(ScreenName.ReceiveConfirmation, { - ...route.params, - accountId: account?.parentId || account.id, - createTokenAccount: account?.triggerCreateAccount, - }); + if (!selectedAccount) { + setSelectedAccount(account.id); + track("account_clicked", { + currency: currency.name, + screen: routerRoute.name, + }); + navigation.navigate(ScreenName.ReceiveConfirmation, { + ...route.params, + accountId: account?.parentId || account.id, + createTokenAccount: account?.triggerCreateAccount, + }); + } }, - [currency.name, navigation, route.params, routerRoute.name], + [ + currency.name, + navigation, + route.params, + routerRoute.name, + selectedAccount, + ], ); const renderItem = useCallback( From e1f7d5a0106021e2ff8f1bfb0182eb5869f2803e Mon Sep 17 00:00:00 2001 From: LFBarreto Date: Fri, 5 Aug 2022 16:01:51 +0200 Subject: [PATCH 2/2] trigger CI