Skip to content

Commit

Permalink
fix: 🐛 Password lock blocked on QRScan (#7822)
Browse files Browse the repository at this point in the history
fix: 🐛 Passwork lock blocked on QRScan
  • Loading branch information
mcayuelas-ledger authored Sep 16, 2024
1 parent 591972a commit bec3c6a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-gifts-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

Block password lock when scanning QR
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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>(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<NavigationProps["navigation"]>();
const onGoBack = () => setCurrentStep(getPreviousStep(currentStep));

useEffect(() => {
setCurrentStep(startingStep);
}, [setCurrentStep]);
}, [isOpened, setCurrentStep]);

const reset = () => {
dispatch(blockPasswordLock(false));
setCurrentStep(startingStep);
setCurrentOption(Options.SCAN);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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>(Options.SCAN);
const navigation = useNavigation<NavigationProps["navigation"]>();
const hasCustomHeader = useMemo(() => currentStep === Steps.QrCodeMethod, [currentStep]);
Expand Down Expand Up @@ -59,6 +64,8 @@ const useActivationDrawerModel = ({ isOpen, startingStep, handleClose }: Props)
button: AnalyticsButton.ScanQRCode,
page: AnalyticsPage.ChooseSyncMethod,
});

dispatch(blockPasswordLock(true));
setCurrentStep(Steps.QrCodeMethod);
};

Expand All @@ -69,6 +76,7 @@ const useActivationDrawerModel = ({ isOpen, startingStep, handleClose }: Props)
const goBackToPreviousStep = () => setCurrentStep(getPreviousStep(currentStep));

const onCloseDrawer = () => {
dispatch(blockPasswordLock(false));
resetStep();
resetOption();
handleClose();
Expand Down

0 comments on commit bec3c6a

Please sign in to comment.