Skip to content

Commit 240e0af

Browse files
authored
Merge pull request #13515 from LedgerHQ/fix/toggle-password
fix: toggle app locked
2 parents 261846a + 82d8b01 commit 240e0af

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

.changeset/cuddly-mice-invite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"live-mobile": minor
3+
---
4+
5+
fix: toggle app locked

apps/ledger-live-mobile/src/screens/Settings/General/AuthSecurityToggle.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from "react";
2-
import { useNavigation } from "@react-navigation/native";
1+
import React, { useState, useCallback } from "react";
2+
import { useNavigation, useFocusEffect } from "@react-navigation/native";
33
import { useSelector } from "~/context/store";
44
import { useTranslation } from "react-i18next";
55
import { Switch } from "@ledgerhq/native-ui";
@@ -16,13 +16,23 @@ export default function AuthSecurityToggle() {
1616
const privacy = useSelector(privacySelector);
1717
const { navigate } = useNavigation();
1818

19+
const [isToggleOn, setIsToggleOn] = useState(!!privacy?.hasPassword);
20+
21+
useFocusEffect(
22+
useCallback(() => {
23+
setIsToggleOn(!!privacy?.hasPassword);
24+
}, [privacy?.hasPassword]),
25+
);
26+
1927
const onValueChange = (authSecurityEnabled: boolean): void => {
2028
track("toggle_clicked", {
2129
toggle: "Password Lock",
2230
page: ScreenName.GeneralSettings,
2331
enabled: !privacy?.hasPassword,
2432
});
2533

34+
setIsToggleOn(authSecurityEnabled);
35+
2636
navigate(
2737
authSecurityEnabled ? NavigatorName.PasswordAddFlow : NavigatorName.PasswordModifyFlow,
2838
);
@@ -40,11 +50,7 @@ export default function AuthSecurityToggle() {
4050
title={t("settings.display.password")}
4151
desc={getPasswordDesc()}
4252
>
43-
<Switch
44-
checked={!!privacy?.hasPassword}
45-
onChange={onValueChange}
46-
testID="password-settings-switch"
47-
/>
53+
<Switch checked={isToggleOn} onChange={onValueChange} testID="password-settings-switch" />
4854
</SettingsRow>
4955
<BiometricsRow />
5056
</>

0 commit comments

Comments
 (0)