From 817a269034cf64fb5df75d316a5b615766f905e1 Mon Sep 17 00:00:00 2001 From: Zishan Mohd Date: Tue, 30 Sep 2025 22:51:22 +0530 Subject: [PATCH] Fix: application error and app stuck on home page --- src/app/(mobile-ui)/home/page.tsx | 8 ++++---- src/app/(mobile-ui)/layout.tsx | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/app/(mobile-ui)/home/page.tsx b/src/app/(mobile-ui)/home/page.tsx index cf4b7ad09..b4464dbb1 100644 --- a/src/app/(mobile-ui)/home/page.tsx +++ b/src/app/(mobile-ui)/home/page.tsx @@ -132,7 +132,7 @@ export default function Home() { // effect for showing balance warning modal useEffect(() => { - if (isFetchingBalance || balance === undefined) return + if (isFetchingBalance || balance === undefined || !user) return if (typeof window !== 'undefined') { const hasSeenBalanceWarning = getFromLocalStorage(`${user!.user.userId}-hasSeenBalanceWarning`) @@ -152,11 +152,11 @@ export default function Home() { setShowBalanceWarningModal(true) } } - }, [balance, isFetchingBalance, showIOSPWAInstallModal, showAddMoneyPromptModal]) + }, [balance, isFetchingBalance, showIOSPWAInstallModal, showAddMoneyPromptModal, user]) // effect for showing balance warning modal useEffect(() => { - if (isFetchingBalance || balance === undefined) return + if (isFetchingBalance || balance === undefined || !user) return if (typeof window !== 'undefined') { const hasSeenBalanceWarning = getFromLocalStorage(`${user!.user.userId}-hasSeenBalanceWarning`) @@ -175,7 +175,7 @@ export default function Home() { setShowBalanceWarningModal(true) } } - }, [balance, isFetchingBalance, showIOSPWAInstallModal, showAddMoneyPromptModal]) + }, [balance, isFetchingBalance, showIOSPWAInstallModal, showAddMoneyPromptModal, user]) // effect for showing add money prompt modal useEffect(() => { diff --git a/src/app/(mobile-ui)/layout.tsx b/src/app/(mobile-ui)/layout.tsx index fd2019b1b..33b0feb11 100644 --- a/src/app/(mobile-ui)/layout.tsx +++ b/src/app/(mobile-ui)/layout.tsx @@ -79,7 +79,14 @@ const Layout = ({ children }: { children: React.ReactNode }) => { // Allow access to public paths without authentication const isPublicPath = publicPathRegex.test(pathName) - if (!isReady || (isFetchingUser && !user && !hasToken && !isPublicPath)) { + // redirect to setup if user is not logged in + useEffect(() => { + if (!isFetchingUser && !user) { + router.push('/setup') + } + }, [user, isFetchingUser, router]) + + if (!isReady || !user || (isFetchingUser && !hasToken && !isPublicPath)) { return (