diff --git a/.changeset/tiny-gifts-matter.md b/.changeset/tiny-gifts-matter.md new file mode 100644 index 000000000000..efd5fb96229c --- /dev/null +++ b/.changeset/tiny-gifts-matter.md @@ -0,0 +1,5 @@ +--- +"live-mobile": patch +--- + +Block password lock when scanning QR diff --git a/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AddAccount/useAddAccountViewModel.ts b/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AddAccount/useAddAccountViewModel.ts index 999a2593598f..53a4a2ef8685 100644 --- a/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AddAccount/useAddAccountViewModel.ts +++ b/apps/ledger-live-mobile/src/newArch/features/Accounts/screens/AddAccount/useAddAccountViewModel.ts @@ -7,6 +7,8 @@ import { useNavigation } from "@react-navigation/native"; import { BaseComposite, StackNavigatorProps } from "~/components/RootNavigator/types/helpers"; import { WalletSyncNavigatorStackParamList } from "~/components/RootNavigator/types/WalletSyncNavigator"; import { useCurrentStep } from "LLM/features/WalletSync/hooks/useCurrentStep"; +import { blockPasswordLock } from "~/actions/appstate"; +import { useDispatch } from "react-redux"; type AddAccountDrawerProps = { isOpened: boolean; @@ -20,18 +22,23 @@ type NavigationProps = BaseComposite< const startingStep = Steps.AddAccountMethod; const useAddAccountViewModel = ({ isOpened, onClose }: AddAccountDrawerProps) => { + const dispatch = useDispatch(); const { currentStep, setCurrentStep } = useCurrentStep(); const [currentOption, setCurrentOption] = useState(Options.SCAN); const navigateToChooseSyncMethod = () => setCurrentStep(Steps.ChooseSyncMethod); - const navigateToQrCodeMethod = () => setCurrentStep(Steps.QrCodeMethod); + const navigateToQrCodeMethod = () => { + dispatch(blockPasswordLock(true)); // Avoid Background on Android + setCurrentStep(Steps.QrCodeMethod); + }; const navigation = useNavigation(); const onGoBack = () => setCurrentStep(getPreviousStep(currentStep)); useEffect(() => { setCurrentStep(startingStep); - }, [setCurrentStep]); + }, [isOpened, setCurrentStep]); const reset = () => { + dispatch(blockPasswordLock(false)); setCurrentStep(startingStep); setCurrentOption(Options.SCAN); }; diff --git a/apps/ledger-live-mobile/src/newArch/features/WalletSync/screens/Activation/useActivationDrawerModel.ts b/apps/ledger-live-mobile/src/newArch/features/WalletSync/screens/Activation/useActivationDrawerModel.ts index 4ae33187ffd4..a5a309f6b14f 100644 --- a/apps/ledger-live-mobile/src/newArch/features/WalletSync/screens/Activation/useActivationDrawerModel.ts +++ b/apps/ledger-live-mobile/src/newArch/features/WalletSync/screens/Activation/useActivationDrawerModel.ts @@ -12,6 +12,8 @@ import { useNavigation } from "@react-navigation/native"; import { BaseComposite, StackNavigatorProps } from "~/components/RootNavigator/types/helpers"; import { WalletSyncNavigatorStackParamList } from "~/components/RootNavigator/types/WalletSyncNavigator"; import { useCurrentStep } from "../../hooks/useCurrentStep"; +import { useDispatch } from "react-redux"; +import { blockPasswordLock } from "~/actions/appstate"; type Props = { isOpen: boolean; @@ -27,9 +29,12 @@ const useActivationDrawerModel = ({ isOpen, startingStep, handleClose }: Props) const { onClickTrack } = useLedgerSyncAnalytics(); const { currentStep, setCurrentStep } = useCurrentStep(); + const dispatch = useDispatch(); + useEffect(() => { setCurrentStep(startingStep); - }, [startingStep, setCurrentStep]); + }, [startingStep, isOpen, setCurrentStep]); + const [currentOption, setCurrentOption] = useState(Options.SCAN); const navigation = useNavigation(); const hasCustomHeader = useMemo(() => currentStep === Steps.QrCodeMethod, [currentStep]); @@ -59,6 +64,8 @@ const useActivationDrawerModel = ({ isOpen, startingStep, handleClose }: Props) button: AnalyticsButton.ScanQRCode, page: AnalyticsPage.ChooseSyncMethod, }); + + dispatch(blockPasswordLock(true)); setCurrentStep(Steps.QrCodeMethod); }; @@ -69,6 +76,7 @@ const useActivationDrawerModel = ({ isOpen, startingStep, handleClose }: Props) const goBackToPreviousStep = () => setCurrentStep(getPreviousStep(currentStep)); const onCloseDrawer = () => { + dispatch(blockPasswordLock(false)); resetStep(); resetOption(); handleClose();