Skip to content

Commit

Permalink
Merge pull request #847 from LedgerHQ/bugfix/LIVE-3222-llm-receive-fl…
Browse files Browse the repository at this point in the history
…ow-multiple-account-issue

Bugfix/Live-3222 LLM receive flow multiple account issue
  • Loading branch information
LFBarreto authored Aug 5, 2022
2 parents 78bd851 + e1f7d5a commit 0293e6c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-pumpkins-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

LLM - Receive flow prevent creation of multiple accounts at the same time
28 changes: 16 additions & 12 deletions apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function AddAccountsAccounts({ navigation, route }: Props) {
const [error, setError] = useState(null);
const [scannedAccounts, setScannedAccounts] = useState<Account[]>([]);
const [cancelled, setCancelled] = useState(false);
const [selectedAccount, setSelectedAccount] = useState<String | null>(null);

const scanSubscription = useRef<any>();

Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -24,6 +24,7 @@ function ReceiveSelectAccount({ navigation, route }: Props) {
const currency = route.params?.currency;
const routerRoute = useRoute();
const { t } = useTranslation();
const [selectedAccount, setSelectedAccount] = useState<String | null>(null);

const accounts = useSelector(
flattenAccountsByCryptoCurrencyScreenSelector(currency),
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 0293e6c

Please sign in to comment.