fix: display selected fiat amount instead of range for taken orders#477
fix: display selected fiat amount instead of range for taken orders#477
Conversation
WalkthroughA single-file refactoring that consolidates fiat amount display logic in the trade detail screen. A new helper method Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/features/trades/screens/trade_detail_screen.dart (1)
105-116: Remove redundant pending status check; use caller'sisPendingvalue instead.The method re-derives
isPendingfromorder.status(line 111), but the caller already determined it fromtradeState.status(line 53). Since OrderState encapsulates the authoritative state, using inconsistent sources (checkingorder.statuswithin the method whiletradeState.statusdrives the caller's logic) risks silent bugs if these fields ever diverge. Pass the already-resolvedisPendingflag as a parameter:Suggested fix
- String _displayFiatAmount(Order order) { + String _displayFiatAmount(Order order, {required bool isPending}) { final isRangeOrder = order.minAmount != null && order.maxAmount != null && order.minAmount != order.maxAmount; - final isPending = order.status == Status.pending; if (isRangeOrder && isPending) { return "${order.minAmount} - ${order.maxAmount}"; } return order.fiatAmount.toString(); }Update call sites to pass the resolved flag:
- amount: _displayFiatAmount(tradeState.order!), + amount: _displayFiatAmount(tradeState.order!, isPending: isPending),
…#480) Use the caller's isPending (from tradeState.status) as single source of truth instead of re-computing it from order.status inside the method. Prevents potential silent bugs if the two sources ever diverge. Addresses CodeRabbit nitpick from PR #477. Co-authored-by: mostronator <mostronator@users.noreply.github.com>
fix #441
Summary by CodeRabbit