Skip to content

Conversation

@seshanthS
Copy link
Collaborator

@seshanthS seshanthS commented Jul 30, 2025

Changes

  • Navigates to the Home or Launch screen based on the document status.
  • If at least one onChain registered document is found, it will navigate to Home.
  • Added isRegistered to the metadata of DocumentCatalog
  • Migration for adding the isRegistered flag is done on the splashScreen during the first launch.

Summary by CodeRabbit

  • New Features

    • Added the ability to track and update the registration status of documents within the app.
    • Introduced migration logic to ensure documents have accurate registration state information.
  • Bug Fixes

    • Improved navigation logic across multiple screens to direct users to the appropriate screen based on the presence of a valid registered document.
  • Chores

    • Enhanced internal logging and analytics for document validation and migration processes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 30, 2025

Walkthrough

This update introduces document registration state tracking across the app. It extends document metadata with an isRegistered flag, adds context provider methods for updating and querying registration, and implements migration logic for legacy documents. Several screens now use conditional navigation based on registered document presence, and the proving flow marks documents as registered after successful on-chain registration or validation.

Changes

Cohort / File(s) Change Summary
Document Registration State & Context
app/src/providers/passportDataProvider.tsx
Adds isRegistered to DocumentMetadata; introduces context methods: updateDocumentRegistrationState, markCurrentDocumentAsRegistered, and checkIfAnyDocumentsNeedMigration; implements logic to update, mark, and check registration state; updates provider to expose these methods.
Document Registration Migration & Validation
app/src/utils/proving/validateDocument.ts
Adds hasAnyValidRegisteredDocument to check for any registered documents; renames and repurposes the previous function as checkAndUpdateRegistrationStates to iterate, validate, migrate, and update registration state for all documents; adds extensive logging and analytics tracking.
Proving Flow Registration Side Effects
app/src/utils/proving/provingMachine.ts
On successful registration or detection of existing on-chain registration, asynchronously marks the current document as registered; logs outcomes; does not alter error or retry flows.
Splash Screen Migration Logic
app/src/screens/misc/SplashScreen.tsx
After migrating legacy storage, checks if any documents need registration migration; if so, runs checkAndUpdateRegistrationStates before proceeding; updates imports accordingly.
Conditional Navigation on Cancel/Unsupported/Not Found
app/src/screens/aesop/PassportOnboardingScreen.tsx,
app/src/screens/passport/PassportCameraScreen.tsx,
app/src/screens/passport/PassportNFCScanScreen.tsx,
app/src/screens/passport/PassportNFCScanScreen.web.tsx,
app/src/screens/passport/UnsupportedPassportScreen.tsx,
app/src/screens/recovery/PassportDataNotFoundScreen.tsx
Updates cancel/exit/unsupported handlers to check for any valid registered document before navigating: if found, navigates to "Home"; otherwise, to "Launch". Introduces asynchronous handlers, uses separate navigation hooks for "Home" and "Launch", and replaces previous unconditional navigation logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Screen
    participant DataProvider
    participant Validator

    User->>Screen: Press Cancel/Exit
    Screen->>Validator: hasAnyValidRegisteredDocument()
    Validator-->>Screen: true/false
    alt Registered document exists
        Screen->>Screen: Navigate to "Home"
    else No registered document
        Screen->>Screen: Navigate to "Launch"
    end
Loading
sequenceDiagram
    participant AppStart
    participant SplashScreen
    participant DataProvider
    participant Validator

    AppStart->>SplashScreen: Mount
    SplashScreen->>DataProvider: checkIfAnyDocumentsNeedMigration()
    DataProvider-->>SplashScreen: true/false
    alt Migration needed
        SplashScreen->>Validator: checkAndUpdateRegistrationStates()
    end
    SplashScreen->>Validator: hasAnyValidRegisteredDocument()
    Validator-->>SplashScreen: true/false
    alt Registered document exists
        SplashScreen->>SplashScreen: Navigate to "Home"
    else
        SplashScreen->>SplashScreen: Navigate to "Launch"
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

codex

Suggested reviewers

  • transphorm
  • remicolin

Poem

In the ledger of docs, a new flag appears,
Marking those registered through code and through years.
Screens now inquire: "Are you home, or still lost?"
Migration ensures no data is tossed.
With each cancel or scan, logic’s refined—
To Home or to Launch, the path’s well-defined.
🗂️✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotfix/validate-documents

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (2)
app/src/screens/recovery/PassportDataNotFoundScreen.tsx (2)

17-18: Duplicate optimization opportunity: Consider consolidating navigation hooks

Same performance optimization opportunity as in UnsupportedPassportScreen. The dual navigation hook pattern is repeated across multiple screens.

Consider creating a custom hook that handles conditional navigation to reduce code duplication across screens:

const useConditionalNavigation = () => {
  const navigation = useNavigation();
  
  const navigateBasedOnDocuments = useCallback(async () => {
    try {
      const hasValidDocument = await hasAnyValidRegisteredDocument();
      const targetScreen = hasValidDocument ? 'Home' : 'Launch';
      navigation.navigate(targetScreen);
      // Add haptic feedback here
    } catch (error) {
      console.error('Error checking document validation:', error);
      navigation.navigate('Launch');
    }
  }, [navigation]);
  
  return navigateBasedOnDocuments;
};

20-27: Critical: Missing error handling in async function

Same critical issue as UnsupportedPassportScreen - the async function needs error handling to prevent crashes.

Apply the same error handling pattern:

  const onPress = async () => {
+    try {
      const hasValidDocument = await hasAnyValidRegisteredDocument();
      if (hasValidDocument) {
        navigateToHome();
      } else {
        navigateToLaunch();
      }
+    } catch (error) {
+      console.error('Error checking document validation:', error);
+      navigateToLaunch();
+    }
  };
🧹 Nitpick comments (6)
app/src/screens/passport/UnsupportedPassportScreen.tsx (1)

23-24: Consider consolidating navigation hooks for better performance

Using two separate navigation hooks when only one will be called could be optimized. Consider using a single navigation hook and passing the route dynamically.

-  const navigateToLaunch = useHapticNavigation('Launch');
-  const navigateToHome = useHapticNavigation('Home');
+  const navigate = useNavigation();
+  const hapticFeedback = useCallback(() => {
+    // Add haptic feedback logic here
+  }, []);
app/src/screens/passport/PassportNFCScanScreen.web.tsx (2)

28-35: Robust conditional navigation logic

The async function properly handles document validation before navigation. Good error handling pattern where async operations are contained within the function.

Consider adding error handling for the async validation call:

 const onCancelPress = 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 registration:', error);
+    navigateToLaunch(); // Fallback to Launch screen
+  }
 };

18-18: Address TypeScript linting issues

The static analysis correctly identifies TypeScript best practices violations.

Apply these fixes for better TypeScript compliance:

-interface PassportNFCScanScreenProps {}
+type PassportNFCScanScreenProps = Record<string, never>;

-const PassportNFCScanScreen: React.FC<PassportNFCScanScreenProps> = ({}) => {
+const PassportNFCScanScreen: React.FC<PassportNFCScanScreenProps> = () => {

Also applies to: 20-20

app/src/screens/aesop/PassportOnboardingScreen.tsx (1)

22-22: Fix TypeScript compliance issues

Same TypeScript improvements needed as in the web version.

-interface PassportOnboardingScreenProps {}
+type PassportOnboardingScreenProps = Record<string, never>;

-> = ({}) => {
+> = () => {

Also applies to: 26-26

app/src/utils/proving/provingMachine.ts (1)

242-253: Consider extracting common registration logic

Both registration marking blocks use identical patterns. Consider extracting to reduce duplication:

const markDocumentAsRegisteredSafely = async (context: string) => {
  try {
    await markCurrentDocumentAsRegistered();
    console.log(`Document marked as registered (${context})`);
  } catch (error) {
    console.error(`Error marking document as registered (${context}):`, error);
  }
};

// Then use:
if (get().circuitType === 'register') {
  markDocumentAsRegisteredSafely('on completion');
}

// And:
markDocumentAsRegisteredSafely('already on-chain');

Also applies to: 728-737

app/src/utils/proving/validateDocument.ts (1)

341-418: Consider performance optimization for large document sets

The function processes documents sequentially, which could be slow with many documents. Consider batch processing:

export async function checkAndUpdateRegistrationStates(): Promise<void> {
  const allDocuments = await getAllDocuments();
  const documentIds = Object.keys(allDocuments);
  
  // Process in batches of 5 to avoid overwhelming the system
  const BATCH_SIZE = 5;
  for (let i = 0; i < documentIds.length; i += BATCH_SIZE) {
    const batch = documentIds.slice(i, i + BATCH_SIZE);
    await Promise.allSettled(
      batch.map(async (documentId) => {
        // ... existing document processing logic
      })
    );
  }
  
  console.log('Registration state check and update completed');
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1892cf7 and efb9291.

📒 Files selected for processing (10)
  • app/src/providers/passportDataProvider.tsx (6 hunks)
  • app/src/screens/aesop/PassportOnboardingScreen.tsx (1 hunks)
  • app/src/screens/misc/SplashScreen.tsx (2 hunks)
  • app/src/screens/passport/PassportCameraScreen.tsx (2 hunks)
  • app/src/screens/passport/PassportNFCScanScreen.tsx (2 hunks)
  • app/src/screens/passport/PassportNFCScanScreen.web.tsx (1 hunks)
  • app/src/screens/passport/UnsupportedPassportScreen.tsx (1 hunks)
  • app/src/screens/recovery/PassportDataNotFoundScreen.tsx (1 hunks)
  • app/src/utils/proving/provingMachine.ts (3 hunks)
  • app/src/utils/proving/validateDocument.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/src/**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit Configuration File

app/src/**/*.{ts,tsx,js,jsx}: Review React Native TypeScript code for:

  • Component architecture and reusability
  • State management patterns
  • Performance optimizations
  • TypeScript type safety
  • React hooks usage and dependencies
  • Navigation patterns

Files:

  • app/src/screens/recovery/PassportDataNotFoundScreen.tsx
  • app/src/screens/misc/SplashScreen.tsx
  • app/src/screens/passport/UnsupportedPassportScreen.tsx
  • app/src/screens/aesop/PassportOnboardingScreen.tsx
  • app/src/screens/passport/PassportNFCScanScreen.web.tsx
  • app/src/screens/passport/PassportNFCScanScreen.tsx
  • app/src/utils/proving/provingMachine.ts
  • app/src/screens/passport/PassportCameraScreen.tsx
  • app/src/utils/proving/validateDocument.ts
  • app/src/providers/passportDataProvider.tsx
🧠 Learnings (2)
app/src/screens/passport/UnsupportedPassportScreen.tsx (1)

Learnt from: transphorm
PR: #636
File: app/src/utils/cameraPermission.ts:19-21
Timestamp: 2025-07-12T22:00:02.041Z
Learning: The Android permission handling in app/src/utils/cameraPermission.ts is robust and properly implemented using PermissionsAndroid.request() and PermissionsAndroid.check(). Previous issues with Android permission assumptions have been resolved in the current implementation.

app/src/screens/passport/PassportCameraScreen.tsx (1)

Learnt from: transphorm
PR: #636
File: app/src/utils/cameraPermission.ts:19-21
Timestamp: 2025-07-12T22:00:02.041Z
Learning: The Android permission handling in app/src/utils/cameraPermission.ts is robust and properly implemented using PermissionsAndroid.request() and PermissionsAndroid.check(). Previous issues with Android permission assumptions have been resolved in the current implementation.

🪛 Biome (2.1.2)
app/src/screens/aesop/PassportOnboardingScreen.tsx

[error] 21-22: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


[error] 26-26: Unexpected empty object pattern.

(lint/correctness/noEmptyPattern)

app/src/screens/passport/PassportNFCScanScreen.web.tsx

[error] 17-18: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


[error] 20-20: Unexpected empty object pattern.

(lint/correctness/noEmptyPattern)

⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: analyze-android
  • GitHub Check: analyze-ios
🔇 Additional comments (23)
app/src/screens/passport/UnsupportedPassportScreen.tsx (1)

17-17: LGTM: Clean import of validation utility

The import follows consistent patterns used across other screens in this PR.

app/src/screens/recovery/PassportDataNotFoundScreen.tsx (1)

12-12: LGTM: Consistent import pattern

The import follows the same pattern established across other screens in this PR.

app/src/screens/misc/SplashScreen.tsx (3)

10-13: LGTM: Well-organized imports for migration functionality

The imports are clearly grouped and support the new migration functionality effectively.

Also applies to: 17-20


44-55: Excellent migration implementation with proper conditional logic

The migration logic is well-implemented with:

  • Conditional execution based on actual need
  • Clear logging for debugging
  • Proper integration with existing error handling

This approach prevents unnecessary work and provides good visibility into the migration process.


57-57: Good integration of document validation in navigation logic

The use of hasAnyValidRegisteredDocument() here is consistent with other screens and properly handles the navigation decision after migration is complete.

app/src/screens/passport/PassportCameraScreen.tsx (2)

26-26: LGTM: Consistent import pattern maintained

The import follows the established pattern across all updated screens.


117-122: Good: Preserved cancel action tracking in navigation hooks

The navigation hooks maintain the action: 'cancel' parameter, which is important for analytics and user behavior tracking.

app/src/screens/passport/PassportNFCScanScreen.tsx (2)

49-49: LGTM: Final consistent import in the navigation update series

The import pattern is consistent across all five updated screens, which aids maintainability.


279-284: Good: Maintained cancel action tracking consistency

Like PassportCameraScreen, this preserves the important action: 'cancel' parameter for proper analytics tracking.

app/src/screens/passport/PassportNFCScanScreen.web.tsx (2)

16-16: Import organization looks good

The import of hasAnyValidRegisteredDocument is properly placed and follows the existing import structure.


21-26: Well-structured navigation hooks

Good separation of concerns by creating dedicated navigation hooks for different destinations. The action metadata properly tracks user intent.

app/src/screens/aesop/PassportOnboardingScreen.tsx (2)

20-20: Consistent import pattern

Good consistency with other screens in using the same validation utility.


28-41: Excellent pattern consistency

The navigation logic follows the exact same pattern as other passport screens, which provides a consistent user experience across the app.

app/src/utils/proving/provingMachine.ts (3)

22-22: Proper import integration

The import is correctly placed within the existing provider imports section.


241-253: Well-implemented async registration marking

The IIFE pattern properly handles the async operation without blocking the state machine flow. Error handling is appropriate - logging for debugging while allowing the app to continue functioning.


727-737: Consistent error handling pattern

Good consistency in using the same async IIFE pattern and error handling approach as the completed state handler.

app/src/utils/proving/validateDocument.ts (2)

333-336: Clean and focused utility function

Simple, well-named function with clear responsibility. Proper async/await usage and leverages existing catalog loading logic.


341-418: Comprehensive migration and validation logic

Excellent error handling with detailed logging for debugging. The function properly handles invalid documents, missing data, and protocol store operations. Good use of analytics tracking for monitoring.

app/src/providers/passportDataProvider.tsx (5)

68-68: Well-designed interface extension

The optional isRegistered property maintains backward compatibility while adding the needed functionality. Good use of optional property for gradual migration.


189-189: Proper default initialization

Correctly initializes new documents as not registered, which is the appropriate default state.


527-532: Clean interface additions

The new method signatures are well-defined with clear parameter types and return promises appropriately.


692-722: Robust implementation of registration state management

All three functions have proper error handling, logging, and follow the established patterns in the codebase. The checkIfAnyDocumentsNeedMigration function efficiently uses some() for early termination.


553-555: Proper context integration

The new functions are correctly integrated into both the context default and the provider state, maintaining consistency with existing patterns.

Also applies to: 612-614

Comment on lines +124 to +131
const onCancelPress = async () => {
const hasValidDocument = await hasAnyValidRegisteredDocument();
if (hasValidDocument) {
navigateToHome();
} else {
navigateToLaunch();
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const onCancelPress = async () => {
const hasValidDocument = await hasAnyValidRegisteredDocument();
if (hasValidDocument) {
navigateToHome();
} else {
navigateToLaunch();
}
};
const onCancelPress = async () => {
try {
const hasValidDocument = await hasAnyValidRegisteredDocument();
if (hasValidDocument) {
navigateToHome();
} else {
navigateToLaunch();
}
} catch (error) {
console.error('Error checking document validation:', error);
navigateToLaunch();
}
};
🤖 Prompt for AI Agents
In app/src/screens/passport/PassportCameraScreen.tsx around lines 124 to 131,
the async function onCancelPress lacks error handling which can cause app
crashes if hasAnyValidRegisteredDocument fails. Wrap the await call and
subsequent navigation logic in a try-catch block. In the catch block, handle or
log the error appropriately to prevent the app from crashing.

Comment on lines +286 to +293
const onCancelPress = async () => {
const hasValidDocument = await hasAnyValidRegisteredDocument();
if (hasValidDocument) {
navigateToHome();
} else {
navigateToLaunch();
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const onCancelPress = async () => {
const hasValidDocument = await hasAnyValidRegisteredDocument();
if (hasValidDocument) {
navigateToHome();
} else {
navigateToLaunch();
}
};
const onCancelPress = async () => {
try {
const hasValidDocument = await hasAnyValidRegisteredDocument();
if (hasValidDocument) {
navigateToHome();
} else {
navigateToLaunch();
}
} catch (error) {
console.error('Error checking document validation:', error);
navigateToLaunch();
}
};
🤖 Prompt for AI Agents
In app/src/screens/passport/PassportNFCScanScreen.tsx around lines 286 to 293,
the onCancelPress function lacks error handling, unlike other screens. Wrap the
async call to hasAnyValidRegisteredDocument and the subsequent navigation calls
in a try-catch block. In the catch block, handle or log the error appropriately
to maintain consistency and robustness. Additionally, consider refactoring this
logic into a shared custom hook to avoid duplication and ensure uniform error
handling across all screens.

Comment on lines +26 to +33
const onPress = async () => {
const hasValidDocument = await hasAnyValidRegisteredDocument();
if (hasValidDocument) {
navigateToHome();
} else {
navigateToLaunch();
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add error handling for async document validation

The async function lacks error handling, which could cause the app to crash if hasAnyValidRegisteredDocument() throws an error.

  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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const onPress = async () => {
const hasValidDocument = await hasAnyValidRegisteredDocument();
if (hasValidDocument) {
navigateToHome();
} else {
navigateToLaunch();
}
};
const onPress = async () => {
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();
}
};
🤖 Prompt for AI Agents
In app/src/screens/passport/UnsupportedPassportScreen.tsx around lines 26 to 33,
the async function onPress calls hasAnyValidRegisteredDocument() without error
handling, risking app crashes if the promise rejects. Wrap the await call in a
try-catch block to catch any errors, and handle them gracefully, such as logging
the error and providing fallback navigation or user feedback.

@seshanthS seshanthS requested a review from remicolin July 30, 2025 19:39
action: 'cancel',
});
const onCancelPress = async () => {
const hasValidDocument = await hasAnyValidRegisteredDocument();
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants