-
Notifications
You must be signed in to change notification settings - Fork 179
fix: navigate home #813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: navigate home #813
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,7 @@ import useUserStore from '../../stores/userStore'; | |||||||||||||||||||||||||||||||||||||||||||
| import analytics from '../../utils/analytics'; | ||||||||||||||||||||||||||||||||||||||||||||
| import { black, slate400, slate800, white } from '../../utils/colors'; | ||||||||||||||||||||||||||||||||||||||||||||
| import { dinot } from '../../utils/fonts'; | ||||||||||||||||||||||||||||||||||||||||||||
| import { hasAnyValidRegisteredDocument } from '../../utils/proving/validateDocument'; | ||||||||||||||||||||||||||||||||||||||||||||
| import { checkScannedInfo, formatDateToYYMMDD } from '../../utils/utils'; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| interface PassportNFCScanScreen {} | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -113,9 +114,21 @@ const PassportCameraScreen: React.FC<PassportNFCScanScreen> = ({}) => { | |||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||
| [store, navigation], | ||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||
| const onCancelPress = useHapticNavigation('Launch', { | ||||||||||||||||||||||||||||||||||||||||||||
| const navigateToLaunch = useHapticNavigation('Launch', { | ||||||||||||||||||||||||||||||||||||||||||||
| action: 'cancel', | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| const navigateToHome = useHapticNavigation('Home', { | ||||||||||||||||||||||||||||||||||||||||||||
| action: 'cancel', | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const onCancelPress = async () => { | ||||||||||||||||||||||||||||||||||||||||||||
| const hasValidDocument = await hasAnyValidRegisteredDocument(); | ||||||||||||||||||||||||||||||||||||||||||||
| if (hasValidDocument) { | ||||||||||||||||||||||||||||||||||||||||||||
| navigateToHome(); | ||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||
| navigateToLaunch(); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+124
to
+131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Add error handling to prevent crashes The async function needs error handling like the other screens to prevent app crashes if document validation fails. const onCancelPress = async () => {
+ try {
const hasValidDocument = await hasAnyValidRegisteredDocument();
if (hasValidDocument) {
navigateToHome();
} else {
navigateToLaunch();
}
+ } catch (error) {
+ console.error('Error checking document validation:', error);
+ navigateToLaunch();
+ }
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||
| <ExpandableBottomLayout.Layout backgroundColor={white}> | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -46,6 +46,7 @@ import { | |||||||||||||||||||||||||||||||||||||||||||
| } from '../../utils/haptic'; | ||||||||||||||||||||||||||||||||||||||||||||
| import { registerModalCallbacks } from '../../utils/modalCallbackRegistry'; | ||||||||||||||||||||||||||||||||||||||||||||
| import { parseScanResponse, scan } from '../../utils/nfcScanner'; | ||||||||||||||||||||||||||||||||||||||||||||
| import { hasAnyValidRegisteredDocument } from '../../utils/proving/validateDocument'; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const { trackEvent } = analytics(); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -275,9 +276,21 @@ const PassportNFCScanScreen: React.FC<PassportNFCScanScreenProps> = ({}) => { | |||||||||||||||||||||||||||||||||||||||||||
| openErrorModal, | ||||||||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const onCancelPress = useHapticNavigation('Launch', { | ||||||||||||||||||||||||||||||||||||||||||||
| const navigateToLaunch = useHapticNavigation('Launch', { | ||||||||||||||||||||||||||||||||||||||||||||
| action: 'cancel', | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| const navigateToHome = useHapticNavigation('Home', { | ||||||||||||||||||||||||||||||||||||||||||||
| action: 'cancel', | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const onCancelPress = async () => { | ||||||||||||||||||||||||||||||||||||||||||||
| const hasValidDocument = await hasAnyValidRegisteredDocument(); | ||||||||||||||||||||||||||||||||||||||||||||
| if (hasValidDocument) { | ||||||||||||||||||||||||||||||||||||||||||||
| navigateToHome(); | ||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||
| navigateToLaunch(); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+286
to
+293
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Critical: Complete the error handling pattern across all screens This is the final screen missing error handling. For consistency and robustness, apply the same error handling pattern used in the other screens. const onCancelPress = async () => {
+ try {
const hasValidDocument = await hasAnyValidRegisteredDocument();
if (hasValidDocument) {
navigateToHome();
} else {
navigateToLaunch();
}
+ } catch (error) {
+ console.error('Error checking document validation:', error);
+ navigateToLaunch();
+ }
};Consider creating the shared custom hook I mentioned earlier to eliminate code duplication and ensure consistent error handling across all screens. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||||||||||||||||||||||||||||||||||||||||||||
| const _cancelScanIfRunning = useCallback(async () => { | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,12 +14,23 @@ import { ExpandableBottomLayout } from '../../layouts/ExpandableBottomLayout'; | |||||||||||||||||||||||||||||||||||||||||||||
| import analytics from '../../utils/analytics'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import { black, white } from '../../utils/colors'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import { notificationError } from '../../utils/haptic'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import { hasAnyValidRegisteredDocument } from '../../utils/proving/validateDocument'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import { styles } from '../prove/ProofRequestStatusScreen'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const { flush: flushAnalytics } = analytics(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const UnsupportedPassportScreen: React.FC = () => { | ||||||||||||||||||||||||||||||||||||||||||||||
| const onPress = useHapticNavigation('Launch'); | ||||||||||||||||||||||||||||||||||||||||||||||
| const navigateToLaunch = useHapticNavigation('Launch'); | ||||||||||||||||||||||||||||||||||||||||||||||
| const navigateToHome = useHapticNavigation('Home'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const onPress = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||
| const hasValidDocument = await hasAnyValidRegisteredDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (hasValidDocument) { | ||||||||||||||||||||||||||||||||||||||||||||||
| navigateToHome(); | ||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| navigateToLaunch(); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+26
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for async document validation The async function lacks error handling, which could cause the app to crash if const onPress = async () => {
- const hasValidDocument = await hasAnyValidRegisteredDocument();
- if (hasValidDocument) {
- navigateToHome();
- } else {
- navigateToLaunch();
- }
+ try {
+ const hasValidDocument = await hasAnyValidRegisteredDocument();
+ if (hasValidDocument) {
+ navigateToHome();
+ } else {
+ navigateToLaunch();
+ }
+ } catch (error) {
+ console.error('Error checking document validation:', error);
+ // Fallback to Launch screen on error
+ navigateToLaunch();
+ }
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||
| notificationError(); | ||||||||||||||||||||||||||||||||||||||||||||||
| // error screen, flush analytics | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is what you where mentioning during the meet, nice that you found a solution