feat: improve maker UX when order is taken by counterpart#251
Conversation
Prevent auto-navigation and show waiting message for makers when their orders are taken, while preserving original behavior for takers.
WalkthroughThis update introduces user role-aware logic for both navigation and displayed messages in order-related flows. Conditional checks now determine navigation and message content based on whether the user is the creator (maker) or taker of an order, with corresponding updates to localization files to support new user-facing messages in English, Spanish, and Italian. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI
participant Notifier
participant Session
User->>UI: Triggers order-related action
UI->>Notifier: handleEvent(action, order)
Notifier->>Session: Get user session and role
Notifier->>Notifier: _isUserCreator(session, order)
alt User is creator and action matches
Notifier-->>UI: Skip navigation
else User is not creator or action does not match
Notifier-->>UI: Navigate to trade detail
end
sequenceDiagram
participant User
participant UI
participant MessageWidget
participant Session
User->>UI: Views order message
UI->>MessageWidget: buildMessage(tradeState)
MessageWidget->>Session: Get user session and role
MessageWidget->>MessageWidget: _isUserCreator(session, tradeState)
alt User is creator and action matches
MessageWidget-->>UI: Show "orderTakenWaitingCounterpart" message
else
MessageWidget-->>UI: Show default waiting message
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
lib/l10n/intl_en.arb (1)
78-86: Keep locale files in sync and fix seconds/minutes wordingGood addition, but please:
- Confirm
orderTakenWaitingCounterpartis also present inintl_it.arb.- Decide whether
expiration_secondsshould be expressed in seconds or minutes to avoid user-visible confusion.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
lib/features/order/notfiers/abstract_mostro_notifier.dart(3 hunks)lib/features/trades/widgets/mostro_message_detail_widget.dart(3 hunks)lib/l10n/intl_en.arb(1 hunks)lib/l10n/intl_es.arb(1 hunks)lib/l10n/intl_it.arb(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
lib/**/*.dart
📄 CodeRabbit Inference Engine (CLAUDE.md)
lib/**/*.dart: UseS.of(context).yourKeyfor all user-facing strings
Always use localized strings instead of hardcoded text
Pass BuildContext to methods that need localization
Always use latest APIs (e.g.,withValues()instead ofwithOpacity())
Always checkmountedbefore using context after async operations
Files:
lib/features/order/notfiers/abstract_mostro_notifier.dartlib/features/trades/widgets/mostro_message_detail_widget.dart
**/*.dart
📄 CodeRabbit Inference Engine (CLAUDE.md)
**/*.dart: Remove unused imports and dependencies
Useconstconstructors where possible
Files:
lib/features/order/notfiers/abstract_mostro_notifier.dartlib/features/trades/widgets/mostro_message_detail_widget.dart
lib/l10n/*.arb
📄 CodeRabbit Inference Engine (CLAUDE.md)
lib/l10n/*.arb: Internationalization must useflutter_intlwith ARB files inlib/l10n/
Use proper ARB metadata for parameterized strings
Files:
lib/l10n/intl_it.arblib/l10n/intl_es.arblib/l10n/intl_en.arb
lib/l10n/intl_{en,es,it}.arb
📄 CodeRabbit Inference Engine (CLAUDE.md)
Add new localization keys to all three ARB files (en, es, it)
Files:
lib/l10n/intl_it.arblib/l10n/intl_es.arblib/l10n/intl_en.arb
lib/features/*/{screens,providers,notifiers,widgets}/**/*.dart
📄 CodeRabbit Inference Engine (CLAUDE.md)
Feature-based organization:
features/{feature}/{screens|providers|notifiers|widgets}/
Files:
lib/features/trades/widgets/mostro_message_detail_widget.dart
🧠 Learnings (17)
📚 Learning: in abstractmostronotifier, state updates occur for all messages regardless of timestamp to hydrate t...
Learnt from: chebizarro
PR: MostroP2P/mobile#127
File: lib/features/order/notfiers/abstract_mostro_notifier.dart:45-54
Timestamp: 2025-06-26T15:03:23.529Z
Learning: In AbstractMostroNotifier, state updates occur for all messages regardless of timestamp to hydrate the OrderNotifier from MostroStorage during sync, while handleEvent is only called for recent messages (within 60 seconds) to prevent re-triggering side effects like notifications and navigation for previously handled messages. This design prevents displaying stale notifications when the app is reopened or brought to the foreground.
Applied to files:
lib/features/order/notfiers/abstract_mostro_notifier.dartlib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: in abstractmostronotifier, the handleevent method is synchronous and returns void, not future....
Learnt from: Catrya
PR: MostroP2P/mobile#215
File: lib/features/order/notfiers/order_notifier.dart:0-0
Timestamp: 2025-07-20T23:33:17.689Z
Learning: In AbstractMostroNotifier, the handleEvent method is synchronous and returns void, not Future<void>. Do not suggest adding await to super.handleEvent() calls as this would cause compilation errors.
Applied to files:
lib/features/order/notfiers/abstract_mostro_notifier.dart
📚 Learning: applies to lib/core/mostro_fsm.dart : order state transitions must be managed by `core/mostro_fsm.da...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/core/mostro_fsm.dart : Order state transitions must be managed by `core/mostro_fsm.dart`
Applied to files:
lib/features/order/notfiers/abstract_mostro_notifier.dartlib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: mostroservice methods like takebuyorder() and takesellorder() return future and trigger side e...
Learnt from: chebizarro
PR: MostroP2P/mobile#110
File: test/notifiers/take_order_notifier_test.dart:72-74
Timestamp: 2025-06-04T19:35:20.209Z
Learning: MostroService methods like takeBuyOrder() and takeSellOrder() return Future<void> and trigger side effects through other mechanisms rather than direct return values. When testing these methods, focus on verifying method calls and testing state changes through the provider system rather than mocking return values.
Applied to files:
lib/features/order/notfiers/abstract_mostro_notifier.dartlib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: in the mostro protocol, an order cannot be canceled unless it has a valid orderid, so null checks on...
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:97-103
Timestamp: 2025-05-06T15:49:55.079Z
Learning: In the Mostro protocol, an order cannot be canceled unless it has a valid orderId, so null checks on orderId during cancel operations are unnecessary.
Applied to files:
lib/features/order/notfiers/abstract_mostro_notifier.dart
📚 Learning: in the context of the mostro mobile app, the `tradestate` class is specifically constructed using th...
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/features/trades/models/trade_state.dart:1-15
Timestamp: 2025-05-08T16:06:33.665Z
Learning: In the context of the Mostro Mobile app, the `TradeState` class is specifically constructed using the `tradeStateProvider`. While some fields are nullable (`lastAction` and `orderPayload`), they are still marked as required parameters to ensure they are explicitly considered during state construction.
Applied to files:
lib/features/order/notfiers/abstract_mostro_notifier.dartlib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/l10n/intl_{en,es,it}.arb : add new localization keys to all three arb files (en, es, ...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/l10n/intl_{en,es,it}.arb : Add new localization keys to all three ARB files (en, es, it)
Applied to files:
lib/l10n/intl_it.arblib/l10n/intl_es.arblib/l10n/intl_en.arb
📚 Learning: applies to lib/l10n/*.arb : use proper arb metadata for parameterized strings...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/l10n/*.arb : Use proper ARB metadata for parameterized strings
Applied to files:
lib/l10n/intl_es.arblib/l10n/intl_en.arb
📚 Learning: in the orderstate refactor, public keys should be accessed via `tradestate.peer?.publickey` from the...
Learnt from: chebizarro
PR: MostroP2P/mobile#110
File: lib/features/trades/widgets/mostro_message_detail_widget.dart:134-141
Timestamp: 2025-06-08T23:54:09.987Z
Learning: In the OrderState refactor, public keys should be accessed via `tradeState.peer?.publicKey` from the OrderState instance rather than through `session?.peer?.publicKey`, as the OrderState encapsulates peer information directly.
Applied to files:
lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: in the mostro mobile codebase, riverpod code generation is used with `@riverpod` annotations. provid...
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:70-76
Timestamp: 2025-05-06T15:49:26.443Z
Learning: In the Mostro Mobile codebase, Riverpod code generation is used with `@Riverpod` annotations. Providers like `eventStorageProvider` are generated in `.g.dart` files from annotated functions in the main provider files. These providers are accessible by importing the main provider file (e.g., `mostro_service_provider.dart`), not by importing a separate provider file.
Applied to files:
lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: use riverpod for all state management...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Use Riverpod for all state management
Applied to files:
lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: in the mostro mobile codebase, `eventstorageprovider` is exported from `package:mostro_mobile/shared...
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:70-76
Timestamp: 2025-05-06T15:49:26.443Z
Learning: In the Mostro Mobile codebase, `eventStorageProvider` is exported from `package:mostro_mobile/shared/providers/mostro_service_provider.dart` and not from a separate `event_storage_provider.dart` file.
Applied to files:
lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/data/models.dart : models must be exported through `data/models.dart`...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/data/models.dart : Models must be exported through `data/models.dart`
Applied to files:
lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/services/nostr_service.dart : all nostr protocol interactions must go through `servic...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/services/nostr_service.dart : All Nostr protocol interactions must go through `services/nostr_service.dart`
Applied to files:
lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/shared/providers/mostro_database_provider.dart : database initialization must occur i...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/shared/providers/mostro_database_provider.dart : Database initialization must occur in `shared/providers/mostro_database_provider.dart`
Applied to files:
lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/features/*/{screens,providers,notifiers,widgets}/**/*.dart : feature-based organizati...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/features/*/{screens,providers,notifiers,widgets}/**/*.dart : Feature-based organization: `features/{feature}/{screens|providers|notifiers|widgets}/`
Applied to files:
lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/features/*/providers/**/*.dart : providers are organized by feature in `features/{fea...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/features/*/providers/**/*.dart : Providers are organized by feature in `features/{feature}/providers/`
Applied to files:
lib/features/trades/widgets/mostro_message_detail_widget.dart
🔇 Additional comments (8)
lib/l10n/intl_it.arb (1)
78-86: LGTM! Well-formed localization entry.The new Italian localization key follows proper ARB format with correct placeholder definition and appropriate message content for the maker waiting scenario.
lib/features/order/notfiers/abstract_mostro_notifier.dart (3)
162-177: Excellent implementation of role-aware navigation for waitingSellerToPay.The conditional logic correctly identifies when the user is a maker of a buy order and prevents automatic navigation, keeping them on the current screen as intended. The logic flows well and maintains the original behavior for takers.
183-192: Good implementation of conditional navigation for waitingBuyerInvoice.The logic properly checks if user is a maker of a sell order and skips navigation accordingly, while preserving the original navigation behavior for other scenarios.
248-255: Well-implemented helper method with proper null safety.The
_isUserCreator()method correctly determines if the current user is the order creator by matching session role with order kind. The null checks ensure robust behavior when session or order data is unavailable.lib/features/trades/widgets/mostro_message_detail_widget.dart (4)
5-6: Appropriate imports added for the new functionality.The Session and OrderState imports are necessary for the role-based message logic being implemented.
112-125: Excellent implementation of role-aware messaging for waitingSellerToPay.The conditional logic correctly identifies makers and shows the appropriate waiting message. The
replaceAll('\\n', '\n')properly handles escaped newlines from the localization string.
134-145: Good implementation of conditional messaging for waitingBuyerInvoice.The logic properly checks both maker status and sell order type before showing the maker-specific message, maintaining consistency with the navigation logic changes.
276-283: Consistent helper method implementation.The
_isUserCreator()method matches the implementation inAbstractMostroNotifier, ensuring consistent role determination logic across both navigation and messaging components.
Summary by CodeRabbit
New Features
Localization