Skip to content

Commit f009400

Browse files
committed
Save
1 parent ef870a9 commit f009400

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-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}>

packages/mobile-app/data/facades/wallet/oreowalletHandlers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export const walletHandlers = f.facade<WalletHandlers>({
3131
);
3232
const account = await oreoWallet.createAccount(network, name);
3333

34+
console.log("accountzzz", account);
35+
3436
return {
3537
name: account.name,
3638
viewOnly: account.viewOnly,
@@ -89,6 +91,8 @@ export const walletHandlers = f.facade<WalletHandlers>({
8991
? await oreoWallet.getActiveAccountWithHeadAndBalances(network)
9092
: await oreoWallet.getAccountWithHeadAndBalances(network, name);
9193

94+
console.log({ name });
95+
9296
if (!account) {
9397
return null;
9498
}

packages/mobile-app/data/wallet/db.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ export class WalletDb {
482482
AccountFormat.Base64Json,
483483
);
484484

485+
console.log("account", account);
486+
485487
const result = await this.db.transaction().execute(async (db) => {
486488
const insertResult = await db
487489
.insertInto("accounts")
@@ -500,13 +502,16 @@ export class WalletDb {
500502
// * If the new account has same public address but different name
501503
// * If the new account has same public address but adds/removes spending key
502504
if (!insertResult.numInsertedOrUpdatedRows) {
505+
console.log("returning existing account");
503506
return await db
504507
.selectFrom("accounts")
505508
.selectAll()
506509
.where("accounts.publicAddress", "=", account.publicAddress)
507510
.executeTakeFirstOrThrow();
508511
}
509512

513+
console.log("returning new account");
514+
510515
// Only set as active account if this was a new insert
511516
await db
512517
.updateTable("activeAccount")
@@ -749,6 +754,8 @@ export class WalletDb {
749754
])
750755
.executeTakeFirst();
751756

757+
console.log("active", account);
758+
752759
if (!account) return;
753760

754761
const head = await db

packages/mobile-app/providers/AccountProvider.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export function AccountProvider({ children }: { children: ReactNode }) {
2525
},
2626
);
2727

28+
console.log(getAccountResult.data);
29+
2830
useEffect(() => {
2931
if (getAccountResult.isLoading) return;
3032

0 commit comments

Comments
 (0)