Skip to content

Commit

Permalink
prevent going back from dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
KKA11010 committed Nov 19, 2023
1 parent c72d5af commit 3ec61b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/screens/Auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export default function AuthPage({ navigation, route }: TAuthPageProps) {
return
}
setSuccess(true)
// navigate to dashboard
navigation.navigate(shouldRemove ? 'Security settings' : 'dashboard')
return
}
Expand Down Expand Up @@ -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')

}
Expand Down
10 changes: 9 additions & 1 deletion src/screens/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 (
<View style={[styles.container, { backgroundColor: color.BACKGROUND }]}>
{/* Balance, Disclaimer & History */}
Expand Down

0 comments on commit 3ec61b8

Please sign in to comment.