Skip to content
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

Refactor: Consolidate Duplicate Navigation Logic into a Utility Function #9113

Open
9 tasks
salimtb opened this issue Apr 2, 2024 · 0 comments
Open
9 tasks

Comments

@salimtb
Copy link
Contributor

salimtb commented Apr 2, 2024

What is this about?

Throughout our codebase, we've identified multiple instances where we're using similar navigation logic to direct users to various webviews. This repetition not only bloats our code but also makes future changes more cumbersome and error-prone. To address this, we propose creating a unified utility function that handles this navigation pattern.

Scenario

No response

Design

No response

Technical Details

Current Implementation
Currently, the navigation to webviews is handled directly within component methods or lifecycle hooks. An example can be found in [insert specific file path or component name here], where we navigate to the security tips webview:

navigation.navigate('Webview', {
  screen: 'SimpleWebview',
  params: {
    url: AppConstants.URLS.SECURITY,
    title: strings('add_asset.banners.custom_security_tips'),
  },
});

This pattern is repeated in several other places within our codebase, leading to duplicated logic.

Proposed Solution
We suggest creating a utility function, potentially within a navigationUtils.js file, that abstracts this common navigation pattern. This function would accept parameters for the URL and title (and any other relevant parameters) and handle the navigation:

// In navigationUtils.js
export function navigateToWebview(url, title) {
  navigation.navigate('Webview', {
    screen: 'SimpleWebview',
    params: { url, title },
  });
}

This approach would allow us to replace all instances of the direct navigation.navigate calls with a single, reusable function call, thereby reducing code duplication and simplifying future updates or changes to our navigation logic.

Threat Modeling Framework

No response

Acceptance Criteria

No response

Stakeholder review needed before the work gets merged

  • Engineering (needed in most cases)
  • Design
  • Product
  • QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
  • Security
  • Legal
  • Marketing
  • Management (please specify)
  • Other (please specify)

References

No response

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

No branches or pull requests

1 participant