Skip to content

Commit

Permalink
Merge pull request #192 from getAlby/task-fix-link-handler
Browse files Browse the repository at this point in the history
fix: do not handle links before onboarding
  • Loading branch information
im-adithya authored Nov 20, 2024
2 parents 5c40ece + 73a57e1 commit 513e1b1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions hooks/useHandleLinking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -31,5 +34,5 @@ export function useHandleLinking() {
);

return () => subscription.remove();
}, [hasSession]);
}, [hasSession, isOnboarded, wallets.length]);
}

0 comments on commit 513e1b1

Please sign in to comment.