Skip to content

Commit e058850

Browse files
authored
Dont prompt for pin after account creation (#124)
1 parent 0abaee1 commit e058850

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/mobile-app/components/PinLockScreen/PinLockScreen.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { PinInputComponent } from "../PinInputComponent";
1111
import { Button, Modal, Card, Text } from "@ui-kitten/components";
1212
import { useCallback, useEffect, useRef, useState } from "react";
13+
import { useSegments } from "expo-router";
1314

1415
const LOCK_TIMEOUT = 60 * 1000 * 5; // 5 minutes of inactivity
1516

@@ -19,6 +20,8 @@ export function PinLockScreen({ children }: { children?: React.ReactNode }) {
1920
const setAppSetting = facade.setAppSetting.useMutation();
2021
const removeAllAccounts = facade.removeAllAccounts.useMutation();
2122
const pin = appSettings.data?.pin;
23+
const segments = useSegments();
24+
const inOnboarding = segments[0] === "onboarding";
2225

2326
const [isLocked, setIsLocked] = useState(true);
2427
const [enteredPin, setEnteredPin] = useState("");
@@ -27,6 +30,12 @@ export function PinLockScreen({ children }: { children?: React.ReactNode }) {
2730
const lastActiveTimestamp = useRef(Date.now());
2831
const lockTimeoutRef = useRef<NodeJS.Timeout>();
2932

33+
useEffect(() => {
34+
if (pin === "" || inOnboarding) {
35+
setIsLocked(false);
36+
}
37+
}, [pin, inOnboarding]);
38+
3039
const resetLockTimeout = useCallback(() => {
3140
if (lockTimeoutRef.current) {
3241
clearTimeout(lockTimeoutRef.current);
@@ -47,7 +56,7 @@ export function PinLockScreen({ children }: { children?: React.ReactNode }) {
4756
if (nextAppState === "active") {
4857
// When app comes to foreground, check if we should lock
4958
const timeSinceLastActive = Date.now() - lastActiveTimestamp.current;
50-
if (timeSinceLastActive >= LOCK_TIMEOUT) {
59+
if (timeSinceLastActive >= LOCK_TIMEOUT && !inOnboarding) {
5160
setIsLocked(true);
5261
}
5362
resetLockTimeout();
@@ -64,7 +73,7 @@ export function PinLockScreen({ children }: { children?: React.ReactNode }) {
6473
return () => {
6574
subscription.remove();
6675
};
67-
}, [isLocked, resetLockTimeout]);
76+
}, [isLocked, resetLockTimeout, inOnboarding]);
6877

6978
// Initial setup of the lock timer
7079
useEffect(() => {
@@ -104,7 +113,7 @@ export function PinLockScreen({ children }: { children?: React.ReactNode }) {
104113
{children}
105114

106115
{/* Lock screen overlay */}
107-
{!!pin && isLocked && (
116+
{!!pin && isLocked && !inOnboarding && (
108117
<View style={styles.lockOverlay}>
109118
<SafeAreaView style={styles.lockContent}>
110119
<View style={styles.pinContainer}>

0 commit comments

Comments
 (0)