Skip to content

Commit

Permalink
Refactor: the redirection from biometrics
Browse files Browse the repository at this point in the history
  • Loading branch information
georgipavlov-7DIGIT committed May 21, 2024
1 parent 6e4100f commit ecb0b7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/blocks/RegisterAnonymous/RegisterAnonymous.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ export const RegisterAnonymous = ({ navigation }) => {
tokenExpiresInPromise,
refreshTokenPromise,
]);
setToken(token);
setTimeout(() => {
setToken(token);
}, 1);
},
onError: (error) => {
const { message: errorMessage } = useError(error);
Expand Down
11 changes: 7 additions & 4 deletions src/navigation/Navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export function Navigation({
isTmpUser,
userPin,
hasCheckedTmpUser,
initialRouteName,
} = useContext(Context);

const getClientDataEnabled = !!(
Expand Down Expand Up @@ -276,7 +277,9 @@ export function Navigation({
/>
) : token && hasCheckedTmpUser ? (
<>
<RedirectToBiometrics />
<RedirectToBiometrics
checkForDeclined={initialRouteName !== "RegisterAboutYou"}
/>
<AppNavigation />
</>
) : (
Expand All @@ -288,20 +291,20 @@ export function Navigation({
);
}

const RedirectToBiometrics = () => {
const RedirectToBiometrics = ({ checkForDeclined }) => {
const navigation = useNavigation();
useEffect(() => {
const checkHasDeclined = async () => {
const hasDeclined = await localStorage.getItem("has-declined-biometrics");
const userPin = await localStorage.getItem("pin-code");
const hasBiometrics = await localStorage.getItem("biometrics-enabled");

if (!hasDeclined && !userPin && !hasBiometrics) {
if (!hasDeclined && !userPin && !hasBiometrics && checkForDeclined) {
navigation.navigate("SetUpBiometrics", { goBackOnSkip: true });
}
};
checkHasDeclined();
}, []);
}, [checkForDeclined]);
return <></>;
};

Expand Down

0 comments on commit ecb0b7c

Please sign in to comment.