-
Notifications
You must be signed in to change notification settings - Fork 8
Fix duplicated logic in SelectedWalletScreen and DRY balance display #534
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
Conversation
📝 WalkthroughWalkthroughTwo Android UI components are refactored for improved code reusability. SelectedWalletScreen extracts transaction computation and load state logic into derived variables, while WalletBalanceHeaderView introduces a new private AmountDisplay composable to centralize amount rendering across hidden, loaded, and loading states. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
- Extract loadState and transactions once to avoid evaluating the when expression twice for overscroll handling - Add AmountDisplay helper composable to eliminate repeated if/else-if/else pattern for hidden/amount/loading states in WalletBalanceHeaderView
39717fa to
85eb04f
Compare
|
@greptile-apps review pr |
Greptile OverviewGreptile SummaryThis PR refactors two key components to eliminate code duplication and improve performance. In Key Changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant SelectedWalletScreen
participant WalletManager
participant BalanceWidget
participant AmountDisplay
User->>SelectedWalletScreen: View wallet
SelectedWalletScreen->>WalletManager: Get loadState
WalletManager-->>SelectedWalletScreen: Return loadState (LOADING/SCANNING/LOADED)
Note over SelectedWalletScreen: Extract loadState once
Note over SelectedWalletScreen: Compute transactions from loadState
alt loadState is SCANNING
SelectedWalletScreen->>SelectedWalletScreen: Use loadState.txns as transactions
else loadState is LOADED
SelectedWalletScreen->>SelectedWalletScreen: Use loadState.txns as transactions
else loadState is LOADING or null
SelectedWalletScreen->>SelectedWalletScreen: Use emptyList() as transactions
end
SelectedWalletScreen->>BalanceWidget: Display balance (primaryAmount, secondaryAmount, isHidden)
BalanceWidget->>AmountDisplay: Render secondary amount
Note over AmountDisplay: Check isHidden → amount → loading states
AmountDisplay-->>BalanceWidget: Display text or spinner
BalanceWidget->>AmountDisplay: Render primary amount
Note over AmountDisplay: Check isHidden → amount → loading states
AmountDisplay-->>BalanceWidget: Display text or spinner
BalanceWidget-->>User: Show balance UI
Note over SelectedWalletScreen: Reuse transactions for<br/>TransactionsCardView rendering
SelectedWalletScreen->>User: Display transactions using pre-computed list
|
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.