-
Notifications
You must be signed in to change notification settings - Fork 20
fix: Prevent combining fixed price with range orders in order creation #439
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
WalkthroughAdds range-order mode propagation and UI/validation to prevent selecting Fixed Price when a max amount is present. The parent screen tracks Changes
Sequence DiagramsequenceDiagram
actor User
participant AmountSection as AmountSection
participant AddOrderScreen as AddOrderScreen
participant PriceTypeSection as PriceTypeSection
User->>AmountSection: Focus max amount (first time)
AmountSection->>AddOrderScreen: onRangeModeChanged(true)
AddOrderScreen->>AddOrderScreen: set _isRangeMode = true
AddOrderScreen->>PriceTypeSection: pass updated props (errorMessage / disabled state)
User->>PriceTypeSection: Attempt toggle to Fixed
PriceTypeSection->>AddOrderScreen: onToggle(request Fixed)
AddOrderScreen->>AddOrderScreen: _showFixedPriceRangeError()
AddOrderScreen->>PriceTypeSection: update errorMessage
PriceTypeSection->>User: display fixedPriceDisabledForRange message
User->>AmountSection: Clear max amount
AmountSection->>AddOrderScreen: onRangeModeChanged(false)
AddOrderScreen->>PriceTypeSection: clear errorMessage / allow Fixed
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
No actionable comments were generated in the recent review. 🎉 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@lib/features/order/screens/add_order_screen.dart`:
- Around line 103-114: The _showFixedPriceRangeError function can start
overlapping timers that clear a newer message early; add a Timer field (e.g.,
_fixedPriceRangeErrorTimer) to the widget, cancel it if non-null and active at
the start of _showFixedPriceRangeError, then create a new
Timer(Duration(seconds:5)) that clears _fixedPriceRangeError inside the mounted
check and assigns null to the timer when it fires; ensure you import dart:async
and cancel the timer in dispose() as well.
In `@lib/l10n/intl_en.arb`:
- Around line 1366-1367: Remove the non-placeholder metadata entry named
"@_comment_range_fixed_price" and leave only the plain localization key
"fixedPriceDisabledForRange" (do not add any `@-prefixed` metadata for it),
ensuring ARB metadata blocks are present only for keys with placeholders; locate
and delete the "@_comment_range_fixed_price" entry near the
"fixedPriceDisabledForRange" key.
In `@lib/l10n/intl_es.arb`:
- Around line 1342-1343: Remove the stray ARB metadata entry named
"@_comment_range_fixed_price" and keep only the actual message key
"fixedPriceDisabledForRange"; locate the pair ("@_comment_range_fixed_price" and
"fixedPriceDisabledForRange") and delete the metadata line so that only the
translation string remains, and ensure any remaining `@-prefixed` metadata is used
only for keys that have placeholders.
In `@lib/l10n/intl_it.arb`:
- Around line 1397-1399: Remove the metadata-only entry
`@_comment_range_fixed_price` from the ARB file because metadata (`@-prefixed`)
should only accompany parameterized keys; keep the user-facing key
fixedPriceDisabledForRange (and its value) intact and delete the separate
"@_comment_range_fixed_price" line so only parameterized strings retain metadata
blocks.
mostronator
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Approved — Clean fix for #434
What it does
Prevents users from selecting fixed price when creating range orders. Shows a temporary error message (5s auto-dismiss) explaining why.
Review
- Logic is correct:
_onRangeModeChangedproperly resets to market rate and clears sats amount when switching to range mode while on fixed price - Good UX: Error message auto-dismisses with timer, properly cancelled in
dispose() - Proper propagation:
AmountSectionnotifies parent of range mode changes via callback - i18n complete: All 3 languages have the new
fixedPriceDisabledForRangestring - No regressions: The toggle in
PriceTypeSectionnow shows error message inline with Column layout
Minor suggestion (non-blocking)
- Consider using a
SnackBarinstead of inline error text for consistency with the rest of the app pattern, but the current approach works well too.
Good contribution! 👍
|
@Catrya please fix conflicts |
# Conflicts: # lib/l10n/intl_en.arb # lib/l10n/intl_es.arb # lib/l10n/intl_it.arb
AndreaDiazCorreia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No esta duplicando la evaluacion de _isRangeMode? veo que en add_order_screen tiene su boolean y que tambien esta en AmountSection, no estaria redundando ahi? de resto lo probe y anda bien, la pregunta es solo curiosidad
No es redundancia, rastrean cosas distintas: en AmountSection el _isRangeMode indica si el usuario interactuó con el campo max (estado de UI), mientras que en AddOrderScreen refleja si la orden es de rango (_isRangeMode && hasMax), que es lo que llega por el callback. |
AndreaDiazCorreia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK
grunch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
fix #434

Now, if someone tries to create a range order at a fixed price, it will not be allowed, and a message will appear for 5 seconds explaining why it remains at market price.
Summary by CodeRabbit
New Features
Localization