fix(live-27196): use useOpenSwap for market/accounts/assets swap navigation#15043
fix(live-27196): use useOpenSwap for market/accounts/assets swap navigation#15043liviuciulinaru wants to merge 1 commit intodevelopfrom
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR standardizes Swap navigation across multiple entry points in Ledger Live Mobile by routing through the shared useOpenSwap hook, including support for preselecting an account/parent account when available.
Changes:
- Update Account and Asset FAB actions to open Swap via
useOpenSwapinstead of hardcodednavigationParams. - Extend
useOpenSwapto acceptdefaultAccount/defaultParentAccountand short-circuit navigation when provided. - Update Quick Actions swap CTA to use
useOpenSwapfor consistent navigation behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/ledger-live-mobile/src/screens/Account/hooks/useAccountActions.tsx | Use useOpenSwap as the Swap action handler on the Account screen. |
| apps/ledger-live-mobile/src/mvvm/features/Swap/index.ts | Add optional defaultAccount/defaultParentAccount inputs and navigate directly when provided. |
| apps/ledger-live-mobile/src/mvvm/features/QuickActions/components/QuickActionsCtas/useQuickActionsCtasViewModel.ts | Replace direct Swap navigation with handleOpenSwap() from useOpenSwap. |
| apps/ledger-live-mobile/src/components/FabActions/hooks/useAssetActions.tsx | Use useOpenSwap for the Asset Swap action, deriving sourceScreenName from the current route. |
You can also share your feedback on Copilot code review. Take the survey.
| const handleOpenSwap = useCallback(() => { | ||
| if (defaultAccount && !isAccountEmpty(defaultAccount)) { | ||
| navigateToSwap(defaultAccount, defaultParentAccount); | ||
| return; | ||
| } |
There was a problem hiding this comment.
useOpenSwap now has a new early-return path when defaultAccount is provided and non-empty. The existing useOpenSwap tests don’t cover this new branch, so regressions in the account/assets entry points could slip in. Please add/extend tests to assert navigation params for both an Account and TokenAccount passed via defaultAccount (including defaultParentAccount handling) and that the account-selection drawer is not opened in this case.
chore: changeset
bb126cc to
31bbe84
Compare
|


✅ Checklist
npx changesetwas attached.📝 Description
swap.navbar.mp4
❓ Context
https://ledgerhq.atlassian.net/browse/LIVE-27196
🧐 Checklist for the PR Reviewers