diff --git a/app/_layout.tsx b/app/_layout.tsx
index 3c8b648..2770c62 100644
--- a/app/_layout.tsx
+++ b/app/_layout.tsx
@@ -47,22 +47,23 @@ SplashScreen.preventAutoHideAsync();
export default function RootLayout() {
const { isDarkColorScheme } = useColorScheme();
const [fontsLoaded, setFontsLoaded] = React.useState(false);
+ const [checkedOnboarding, setCheckedOnboarding] = React.useState(false);
useConnectionChecker();
const rootNavigationState = useRootNavigationState();
const hasNavigationState = !!rootNavigationState?.key;
- React.useEffect(() => {
- const checkOnboardingStatus = async () => {
- const hasOnboarded = await secureStorage.getItem(hasOnboardedKey);
- if (!hasOnboarded && hasNavigationState) {
- router.replace("/onboarding");
- }
- };
+ async function checkOnboardingStatus() {
+ const hasOnboarded = await secureStorage.getItem(hasOnboardedKey);
+ if (!hasOnboarded && hasNavigationState) {
+ router.replace("/onboarding");
+ }
- checkOnboardingStatus();
+ setCheckedOnboarding(true);
+ };
+
+ async function loadFonts() {
- (async () => {
await Font.loadAsync({
OpenRunde: require("./../assets/fonts/OpenRunde-Regular.otf"),
"OpenRunde-Medium": require("./../assets/fonts/OpenRunde-Medium.otf"),
@@ -71,12 +72,27 @@ export default function RootLayout() {
});
setFontsLoaded(true);
- })().finally(() => {
- SplashScreen.hideAsync();
- });
+ }
+
+ React.useEffect(() => {
+ const init = async () => {
+ try {
+ await Promise.all([
+ checkOnboardingStatus(),
+ loadFonts(),
+ ]);
+ }
+ finally {
+
+ SplashScreen.hideAsync();
+ }
+ };
+
+ init();
+
}, [hasNavigationState]);
- if (!fontsLoaded) {
+ if (!fontsLoaded || !checkedOnboarding) {
return null;
}
diff --git a/app/home.js b/app/home.js
deleted file mode 100644
index 6aff2aa..0000000
--- a/app/home.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import { Home } from "../pages/Home";
-
-export default function Page() {
- return ;
-}
diff --git a/app/index.js b/app/index.js
index bac14c0..6aff2aa 100644
--- a/app/index.js
+++ b/app/index.js
@@ -1,5 +1,5 @@
-import { Index } from "../pages/Index";
+import { Home } from "../pages/Home";
export default function Page() {
- return ;
+ return ;
}
diff --git a/hooks/useOnboarding.ts b/hooks/useOnboarding.ts
new file mode 100644
index 0000000..aa183a5
--- /dev/null
+++ b/hooks/useOnboarding.ts
@@ -0,0 +1,19 @@
+import { hasOnboardedKey } from "lib/state/appStore";
+import React from "react";
+import { useEffect } from "react";
+import { secureStorage } from "~/lib/secureStorage";
+
+export function useOnboarding() {
+ const [onboarded, setOnboarded] = React.useState(false);
+ useEffect(() => {
+ async function checkOnboardingStatus() {
+ await secureStorage.removeItem(hasOnboardedKey);
+ const hasOnboarded = await secureStorage.getItem(hasOnboardedKey);
+ setOnboarded(!!hasOnboarded);
+ };
+
+ checkOnboardingStatus();
+ });
+
+ return onboarded;
+}
diff --git a/pages/Home.tsx b/pages/Home.tsx
index cbf6cf1..7f258bc 100644
--- a/pages/Home.tsx
+++ b/pages/Home.tsx
@@ -21,6 +21,7 @@ import LargeArrowDown from "~/components/icons/LargeArrowDown";
import { SvgProps } from "react-native-svg";
import { Button } from "~/components/ui/button";
import Screen from "~/components/Screen";
+import { useOnboarding } from "~/hooks/useOnboarding";
dayjs.extend(relativeTime);
@@ -40,6 +41,7 @@ export function Home() {
);
const [pressed, setPressed] = React.useState(false);
const rootNavigationState = useRootNavigationState();
+ const isOnboarded = useOnboarding();
useFocusEffect(() => {
reloadBalance();
@@ -48,10 +50,11 @@ export function Home() {
let hasNavigationState = !!rootNavigationState?.key;
const hasNwcClient = !!nwcClient;
React.useEffect(() => {
- if (hasNavigationState && !hasNwcClient) {
+ if (hasNavigationState && !hasNwcClient && isOnboarded) {
router.replace(`/settings/wallets/${selectedWalletId}/wallet-connection`);
}
- }, [hasNwcClient, hasNavigationState]);
+ }, [hasNwcClient, hasNavigationState, isOnboarded]);
+
if (!nwcClient) {
return ;
}
diff --git a/pages/Index.tsx b/pages/Index.tsx
deleted file mode 100644
index d7d4544..0000000
--- a/pages/Index.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import { router } from "expo-router";
-import React, { useEffect } from "react";
-import Loading from "~/components/Loading";
-import { secureStorage } from "~/lib/secureStorage";
-import { hasOnboardedKey } from "~/lib/state/appStore";
-
-export function Index() {
-
- useEffect(() => {
- async function checkOnboardingStatus() {
- const hasOnboarded = await secureStorage.getItem(hasOnboardedKey);
- router.replace(!hasOnboarded ? "/onboarding" : "/home");
- };
- checkOnboardingStatus();
- })
-
- return (
- <>>
- );
-}
diff --git a/pages/Onboarding.tsx b/pages/Onboarding.tsx
index d817047..187358e 100644
--- a/pages/Onboarding.tsx
+++ b/pages/Onboarding.tsx
@@ -10,7 +10,7 @@ import { hasOnboardedKey } from "~/lib/state/appStore";
export function Onboarding() {
async function finish() {
secureStorage.setItem(hasOnboardedKey, "true");
- router.replace("/home");
+ router.replace("/");
}
return (
diff --git a/pages/receive/ReceiveSuccess.tsx b/pages/receive/ReceiveSuccess.tsx
index f0c97f3..311a955 100644
--- a/pages/receive/ReceiveSuccess.tsx
+++ b/pages/receive/ReceiveSuccess.tsx
@@ -47,7 +47,7 @@ export function ReceiveSuccess() {