@@ -10,6 +10,7 @@ import {
10
10
import { PinInputComponent } from "../PinInputComponent" ;
11
11
import { Button , Modal , Card , Text } from "@ui-kitten/components" ;
12
12
import { useCallback , useEffect , useRef , useState } from "react" ;
13
+ import { useSegments } from "expo-router" ;
13
14
14
15
const LOCK_TIMEOUT = 60 * 1000 * 5 ; // 5 minutes of inactivity
15
16
@@ -19,6 +20,8 @@ export function PinLockScreen({ children }: { children?: React.ReactNode }) {
19
20
const setAppSetting = facade . setAppSetting . useMutation ( ) ;
20
21
const removeAllAccounts = facade . removeAllAccounts . useMutation ( ) ;
21
22
const pin = appSettings . data ?. pin ;
23
+ const segments = useSegments ( ) ;
24
+ const inOnboarding = segments [ 0 ] === "onboarding" ;
22
25
23
26
const [ isLocked , setIsLocked ] = useState ( true ) ;
24
27
const [ enteredPin , setEnteredPin ] = useState ( "" ) ;
@@ -27,6 +30,12 @@ export function PinLockScreen({ children }: { children?: React.ReactNode }) {
27
30
const lastActiveTimestamp = useRef ( Date . now ( ) ) ;
28
31
const lockTimeoutRef = useRef < NodeJS . Timeout > ( ) ;
29
32
33
+ useEffect ( ( ) => {
34
+ if ( pin === "" || inOnboarding ) {
35
+ setIsLocked ( false ) ;
36
+ }
37
+ } , [ pin , inOnboarding ] ) ;
38
+
30
39
const resetLockTimeout = useCallback ( ( ) => {
31
40
if ( lockTimeoutRef . current ) {
32
41
clearTimeout ( lockTimeoutRef . current ) ;
@@ -47,7 +56,7 @@ export function PinLockScreen({ children }: { children?: React.ReactNode }) {
47
56
if ( nextAppState === "active" ) {
48
57
// When app comes to foreground, check if we should lock
49
58
const timeSinceLastActive = Date . now ( ) - lastActiveTimestamp . current ;
50
- if ( timeSinceLastActive >= LOCK_TIMEOUT ) {
59
+ if ( timeSinceLastActive >= LOCK_TIMEOUT && ! inOnboarding ) {
51
60
setIsLocked ( true ) ;
52
61
}
53
62
resetLockTimeout ( ) ;
@@ -64,7 +73,7 @@ export function PinLockScreen({ children }: { children?: React.ReactNode }) {
64
73
return ( ) => {
65
74
subscription . remove ( ) ;
66
75
} ;
67
- } , [ isLocked , resetLockTimeout ] ) ;
76
+ } , [ isLocked , resetLockTimeout , inOnboarding ] ) ;
68
77
69
78
// Initial setup of the lock timer
70
79
useEffect ( ( ) => {
@@ -104,7 +113,7 @@ export function PinLockScreen({ children }: { children?: React.ReactNode }) {
104
113
{ children }
105
114
106
115
{ /* Lock screen overlay */ }
107
- { ! ! pin && isLocked && (
116
+ { ! ! pin && isLocked && ! inOnboarding && (
108
117
< View style = { styles . lockOverlay } >
109
118
< SafeAreaView style = { styles . lockContent } >
110
119
< View style = { styles . pinContainer } >
0 commit comments