diff --git a/src/screens/Auth/index.tsx b/src/screens/Auth/index.tsx index 8ffdb3cb..7d378a58 100644 --- a/src/screens/Auth/index.tsx +++ b/src/screens/Auth/index.tsx @@ -124,7 +124,6 @@ export default function AuthPage({ navigation, route }: TAuthPageProps) { return } setSuccess(true) - // navigate to dashboard navigation.navigate(shouldRemove ? 'Security settings' : 'dashboard') return } @@ -183,7 +182,6 @@ export default function AuthPage({ navigation, route }: TAuthPageProps) { } // skip pin setup await store.set(STORE_KEYS.pinSkipped, '1') - // check if initial explainer has been viewed navigation.navigate(shouldEdit ? 'Security settings' : 'dashboard') } diff --git a/src/screens/Dashboard.tsx b/src/screens/Dashboard.tsx index 119313cf..25e541fb 100644 --- a/src/screens/Dashboard.tsx +++ b/src/screens/Dashboard.tsx @@ -11,8 +11,9 @@ import { addMint, getBalance, getMintsUrls, hasMints } from '@db' import { l } from '@log' import OptsModal from '@modal/OptsModal' import TrustMintModal from '@modal/TrustMint' -import type { TDashboardPageProps } from '@model/nav' +import type { TBeforeRemoveEvent, TDashboardPageProps } from '@model/nav' import BottomNav from '@nav/BottomNav' +import { preventBack } from '@nav/utils' import { useFocusClaimContext } from '@src/context/FocusClaim' import { useInitialURL } from '@src/context/Linking' import { useNostrContext } from '@src/context/Nostr' @@ -284,6 +285,13 @@ export default function Dashboard({ navigation, route }: TDashboardPageProps) { return focusHandler }, [navigation]) + // prevent back navigation - https://reactnavigation.org/docs/preventing-going-back/ + useEffect(() => { + const backHandler = (e: TBeforeRemoveEvent) => preventBack(e, navigation.dispatch) + navigation.addListener('beforeRemove', backHandler) + return () => navigation.removeListener('beforeRemove', backHandler) + }, [navigation]) + return ( {/* Balance, Disclaimer & History */}