From 73a57e18f02efc25b2d9a1551e63c08e49858703 Mon Sep 17 00:00:00 2001 From: im-adithya Date: Mon, 18 Nov 2024 18:13:21 +0530 Subject: [PATCH] fix: do not handle links before onboarding --- hooks/useHandleLinking.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hooks/useHandleLinking.ts b/hooks/useHandleLinking.ts index bd817780..8920c1fd 100644 --- a/hooks/useHandleLinking.ts +++ b/hooks/useHandleLinking.ts @@ -2,15 +2,18 @@ import * as Linking from "expo-linking"; import { getInitialURL } from "expo-linking"; import { useEffect } from "react"; import { handleLink } from "~/lib/link"; +import { useAppStore } from "~/lib/state/appStore"; import { useSession } from "./useSession"; export function useHandleLinking() { const { hasSession } = useSession(); + const isOnboarded = useAppStore((store) => store.isOnboarded); + const wallets = useAppStore((store) => store.wallets); useEffect(() => { - // Do not process any deep links until the user authenticated - // This prevents redirect loops between the deep link and /unlock - if (!hasSession) { + // Do not process any deep links until the user is onboarded and authenticated + // This prevents redirect loops between the deep link and /unlock, /onboarding + if (!hasSession || !isOnboarded || !wallets.length) { return; } @@ -31,5 +34,5 @@ export function useHandleLinking() { ); return () => subscription.remove(); - }, [hasSession]); + }, [hasSession, isOnboarded, wallets.length]); }