-
Notifications
You must be signed in to change notification settings - Fork 16
Dispute Listing #304
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
Dispute Listing #304
Conversation
…pub from user notifications
WalkthroughReplaces mock dispute flows with session/order-backed retrieval and UI view models; adds DisputeDescriptionKey.initiatedPendingAdmin and i18n keys; gates disputes UI to debug builds; attaches orderId on dispute initiation; updates repository, providers, widgets, notifier, and localization; minor service delay increase. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as DisputesList (UI)
participant Prov as userDisputeDataProvider
participant Repo as DisputeRepository
participant Sess as sessionNotifierProvider
participant Ord as orderNotifierProvider(orderId)
User->>UI: Open Disputes screen
UI->>Prov: ref.watch(userDisputeDataProvider)
Prov->>Repo: getUserDisputes()
Repo->>Sess: read sessions
loop per session with orderId
Repo->>Ord: read order state
Ord-->>Repo: orderState (may include dispute)
Repo-->>Repo: collect dispute if present
end
Repo-->>Prov: List<Dispute>
Prov->>Sess: read sessions
loop per dispute
Prov->>Ord: find matching order state
Ord-->>Prov: orderState | null
Prov-->>Prov: build DisputeData (include order context if found)
end
Prov-->>UI: AsyncValue<List<DisputeData>>
UI-->>User: Render loading / error / empty / list
sequenceDiagram
autonumber
participant Notifier as AbstractMostroNotifier
participant State as OrderState
participant Bus as NotificationBus
Note over Notifier,State: On dispute initiation actions
Notifier->>Notifier: disputeWithOrderId = dispute.copy(orderId: currentOrderId)
Notifier->>State: state = state.copyWith(dispute: disputeWithOrderId)
State-->>Notifier: updated state
Notifier->>Bus: sendNotification(eventId, payload with dispute_id)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used📓 Path-based instructions (2)lib/l10n/intl_{en,es,it}.arb📄 CodeRabbit inference engine (CLAUDE.md)
Files:
lib/l10n/*.arb📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-09-18T17:17:38.944ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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: 9
🧹 Nitpick comments (3)
lib/services/dispute_service.dart (1)
52-54: Remove duplicate delay in mock implementationThe method now has two identical 200ms delays (lines 52 and 54), effectively making the total delay 400ms. This appears to be unintentional duplication.
Future<void> sendDisputeMessage(String disputeId, String message) async { // Mock implementation await Future.delayed(const Duration(milliseconds: 200)); - // Mock implementation - await Future.delayed(const Duration(milliseconds: 200)); }lib/features/disputes/widgets/disputes_list.dart (1)
17-17: Consider adding const to CircularProgressIndicator.- loading: () => const Center(child: CircularProgressIndicator()), + loading: () => const Center(child: const CircularProgressIndicator()),lib/features/disputes/providers/dispute_providers.dart (1)
41-78: Log caught errors in userDisputeDataProvider instead of silently swallowing.rg output shows this catch in lib/features/disputes/providers/dispute_providers.dart is the only similar catch; swallowing errors hides failures—add debug-only logging.
File: lib/features/disputes/providers/dispute_providers.dart (lines 41–78)
} catch (e) { // Continue checking other sessions + // Consider logging for debugging in development + // if (kDebugMode) { + // debugPrint('Failed to read order state: $e'); + // } continue; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
lib/data/models/dispute.dart(4 hunks)lib/data/repositories/dispute_repository.dart(2 hunks)lib/features/chat/screens/chat_rooms_list.dart(4 hunks)lib/features/disputes/providers/dispute_providers.dart(3 hunks)lib/features/disputes/widgets/dispute_status_content.dart(1 hunks)lib/features/disputes/widgets/disputes_list.dart(1 hunks)lib/features/order/notfiers/abstract_mostro_notifier.dart(2 hunks)lib/l10n/intl_en.arb(2 hunks)lib/l10n/intl_es.arb(2 hunks)lib/l10n/intl_it.arb(2 hunks)lib/services/dispute_service.dart(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
{lib/*.dart,lib/!(generated)/**/*.dart}
📄 CodeRabbit inference engine (CLAUDE.md)
{lib/*.dart,lib/!(generated)/**/*.dart}: Use localized strings; replace hardcoded user-facing text withS.of(context).keyName
Preferconstconstructors andconstwhere possible
Use latest Flutter/Dart APIs (e.g.,withValues()instead of deprecatedwithOpacity())
Files:
lib/services/dispute_service.dartlib/features/disputes/widgets/dispute_status_content.dartlib/features/disputes/widgets/disputes_list.dartlib/data/repositories/dispute_repository.dartlib/features/chat/screens/chat_rooms_list.dartlib/features/order/notfiers/abstract_mostro_notifier.dartlib/data/models/dispute.dartlib/features/disputes/providers/dispute_providers.dart
{lib/*.dart,lib/!(generated)/**/*.dart,test/**/*.dart}
📄 CodeRabbit inference engine (CLAUDE.md)
{lib/*.dart,lib/!(generated)/**/*.dart,test/**/*.dart}: Checkmountedbefore usingBuildContextafterawait(async gaps)
Remove unused imports and dependencies
Files:
lib/services/dispute_service.dartlib/features/disputes/widgets/dispute_status_content.dartlib/features/disputes/widgets/disputes_list.dartlib/data/repositories/dispute_repository.dartlib/features/chat/screens/chat_rooms_list.dartlib/features/order/notfiers/abstract_mostro_notifier.dartlib/data/models/dispute.dartlib/features/disputes/providers/dispute_providers.dart
**/*.dart
📄 CodeRabbit inference engine (CLAUDE.md)
All code comments, variable names, and function names must be in English
Files:
lib/services/dispute_service.dartlib/features/disputes/widgets/dispute_status_content.dartlib/features/disputes/widgets/disputes_list.dartlib/data/repositories/dispute_repository.dartlib/features/chat/screens/chat_rooms_list.dartlib/features/order/notfiers/abstract_mostro_notifier.dartlib/data/models/dispute.dartlib/features/disputes/providers/dispute_providers.dart
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_es.arblib/l10n/intl_it.arblib/l10n/intl_en.arb
🧠 Learnings (5)
📚 Learning: 2025-08-28T20:32:34.625Z
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-28T20:32:34.625Z
Learning: Applies to test/mocks.mocks.dart : Do not manually modify `test/mocks.mocks.dart` (auto-generated by Mockito)
Applied to files:
lib/services/dispute_service.dart
📚 Learning: 2025-08-28T20:32:34.625Z
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-28T20:32:34.625Z
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_es.arblib/l10n/intl_it.arblib/l10n/intl_en.arb
📚 Learning: 2025-08-28T20:32:34.625Z
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-28T20:32:34.625Z
Learning: Use Riverpod for state management with Notifiers encapsulating business logic; access data only through repositories
Applied to files:
lib/data/repositories/dispute_repository.dartlib/features/disputes/providers/dispute_providers.dart
📚 Learning: 2025-05-06T15:49:26.443Z
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/chat/screens/chat_rooms_list.dart
📚 Learning: 2025-06-26T15:03:23.529Z
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.dart
🪛 RuboCop (1.76.1)
lib/l10n/intl_es.arb
[warning] 613-613: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
[warning] 719-719: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
[warning] 721-721: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
lib/l10n/intl_it.arb
[warning] 678-678: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
[warning] 773-773: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
[warning] 775-775: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
lib/l10n/intl_en.arb
[warning] 296-296: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
[warning] 713-713: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
[warning] 715-715: Duplicated key in hash literal.
(Lint/DuplicateHashKey)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (18)
lib/features/order/notfiers/abstract_mostro_notifier.dart (2)
275-291: Good implementation of dispute-order associationThe logic correctly creates a copy of the dispute with the orderId before updating the state, ensuring disputes are properly linked to their corresponding orders for the listing feature.
293-309: Consistent implementation for peer-initiated disputesThe same pattern is correctly applied for peer-initiated disputes, maintaining consistency with the disputeInitiatedByYou case.
lib/features/disputes/widgets/dispute_status_content.dart (1)
127-128: Good implementation of pending admin stateThe new case correctly handles the
initiatedPendingAdminstate, providing appropriate user feedback when a dispute is waiting for admin assignment.lib/data/models/dispute.dart (3)
9-9: Well-structured enum addition for pending admin stateThe new
initiatedPendingAdminenum value appropriately represents the dispute state when waiting for admin assignment, fitting well within the existing dispute lifecycle states.
379-380: Good defensive programming with fallback orderIdThe implementation properly handles null orderId by falling back to the order ID from orderState, ensuring disputes maintain their order association even when the orderId field is missing.
431-436: Logical state transition for pending admin disputesThe switch case correctly returns
initiatedPendingAdminwhen the creator status is unknown (null), which appropriately represents disputes awaiting admin assignment where the initiator hasn't been determined yet.lib/features/chat/screens/chat_rooms_list.dart (3)
3-3: LGTM! Appropriate use of foundation for debug mode checks.The import is correctly added to support
kDebugModechecks for debug-only UI features.
105-107: Good implementation of environment-specific text.The conditional text display correctly shows tab-specific descriptions in debug mode while falling back to a safe, user-friendly message in release mode.
116-139: Swipe gesture implementation looks good.The horizontal swipe detection for tab switching is properly gated to debug mode only, preventing end users from accessing the disputes tab in production.
lib/data/repositories/dispute_repository.dart (1)
9-9: LGTM! Necessary import for order state access.The import is correctly added to support reading order states for dispute retrieval.
lib/features/disputes/providers/dispute_providers.dart (3)
3-10: LGTM! Imports properly organized for real data flow.The imports correctly bring in the necessary models and providers to support the transition from mock to real dispute data.
21-25: Provider correctly uses repository for real data.The implementation properly fetches dispute details from the repository instead of using mock data.
71-76: Good fallback handling for DisputeData creation.The code properly handles both cases - when matching order state is found and when it's not, ensuring DisputeData is always created.
lib/features/disputes/widgets/disputes_list.dart (5)
2-6: LGTM! Widget properly migrated to ConsumerWidget.The migration from StatelessWidget to ConsumerWidget is correctly implemented to support Riverpod state management.
14-15: Excellent use of AsyncValue pattern.The implementation properly watches the userDisputeDataProvider and handles all async states (loading, error, data).
36-39: Good implementation of retry functionality.The error state properly includes a retry button that refreshes the provider, giving users a way to recover from transient failures.
43-74: Well-designed empty state UI.The empty state properly differentiates between "no disputes" and provides helpful context with localized messages.
76-89: ListView implementation looks correct.The ListView properly renders DisputeListItem widgets with navigation to dispute details.
This PR implements dispute listing functionality by connecting real data from Mostro dispute DMs to the existing UI components. When users create disputes, they now appear automatically in the debug-only "Disputes" tab with actual order information instead of mock data. Key improvements include: proper dispute-to-order association via orderId, enhanced DisputeData creation with OrderState context for displaying real order IDs and statuses, and improved provider logic to match disputes with their corresponding sessions. The dispute list is currently visible only in debug mode to prevent exposure to end users until the complete dispute resolution system is ready.
Summary by CodeRabbit
New Features
UI/UX
Localization
Bug Fixes