Skip to content

Conversation

@AndreaDiazCorreia
Copy link
Member

@AndreaDiazCorreia AndreaDiazCorreia commented Jun 10, 2025

Fix #115: Show all payment methods separated by commas in both order list items and detail view, instead of showing only the first method.

image

Summary by CodeRabbit

  • Improvements
    • Updated payment method displays to show all payment methods as a comma-separated list instead of just the first one.
    • Enhanced text handling to prevent overflow, ensuring long payment method lists are displayed gracefully.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 10, 2025

Walkthrough

The changes update the display of payment methods in both the order list item widget and the take order screen. Instead of showing only the first payment method, all payment methods are now shown as a comma-separated string, with improved text overflow handling for better visual presentation. The underlying data extraction was also improved to correctly parse multiple payment methods from the event tags.

Changes

File(s) Change Summary
lib/features/home/widgets/order_list_item.dart Updated to display all payment methods joined by commas, wrapped text in Expanded, added ellipsis.
lib/features/order/screens/take_order_screen.dart Modified to concatenate and display all payment methods, updated label to plural, adjusted variable.
lib/data/models/nostr_event.dart Changed paymentMethods getter to extract all payment methods from tags list instead of splitting one string.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant OrderListItemWidget
    participant OrderData

    User->>OrderListItemWidget: View order card
    OrderListItemWidget->>OrderData: Fetch paymentMethods list
    OrderListItemWidget->>OrderListItemWidget: Join paymentMethods with commas
    OrderListItemWidget->>User: Display all payment methods (comma-separated, ellipsis if overflow)
Loading
sequenceDiagram
    participant User
    participant TakeOrderScreen
    participant OrderData

    User->>TakeOrderScreen: View seller amount section
    TakeOrderScreen->>OrderData: Fetch paymentMethods list
    TakeOrderScreen->>TakeOrderScreen: Join paymentMethods with commas
    TakeOrderScreen->>User: Display all payment methods (comma-separated, plural label)
Loading

Assessment against linked issues

Objective Addressed Explanation
Show all payment methods on order cards, side by side, with overflow handled (Issue #115)

Poem

A rabbit hops with code delight,
Payment methods now in sight—
No longer just the very first,
All are shown, well-rehearsed!
With commas, lines, and overflow,
Every method gets to show.
🐇💳✨


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
lib/features/home/widgets/order_list_item.dart (1)

223-234: Good implementation with one clarity concern.

The changes correctly implement the requirement to display all payment methods as a comma-separated string. The Expanded widget and TextOverflow.ellipsis are excellent additions for handling long payment method lists gracefully.

However, the fallback text 'tm' is unclear and inconsistent with the more descriptive fallback used in the other file.

Consider using a more descriptive fallback text:

-                            : 'tm',
+                            : 'No payment methods',
lib/features/order/screens/take_order_screen.dart (1)

63-65: Correct implementation with minor text inconsistency.

The logic correctly joins all payment methods with commas and the variable name change to methods is appropriate for the plural context.

Consider making the fallback text consistent with the plural label:

-        : 'No payment method';
+        : 'No payment methods';
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67bc68f and 1cb3ddb.

📒 Files selected for processing (2)
  • lib/features/home/widgets/order_list_item.dart (1 hunks)
  • lib/features/order/screens/take_order_screen.dart (2 hunks)
🔇 Additional comments (1)
lib/features/order/screens/take_order_screen.dart (1)

88-88: Good label update to plural form.

The label correctly reflects that multiple payment methods may be displayed.

Copy link
Member

@Catrya Catrya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AndreaDiazCorreia it's not working for me. Look at the event there with several payment methods, but only one is shown in the app.
image

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/data/models/nostr_event.dart (1)

22-28: Collect payment methods from all pm tags, not just the first

firstWhere stops at the first match, so any additional pm tags in the event are silently ignored.
If the protocol ever allows (or already produces) several pm tags – e.g. one per method – the current implementation will under-report methods and the UI will still show an incomplete list.

-    final tag = tags?.firstWhere((t) => t[0] == 'pm', orElse: () => []);
-    if (tag != null && tag.length > 1) {
-      return tag.sublist(1);
-    }
-    return [];
+    final pmTags = tags
+        ?.where((t) => t.isNotEmpty && t.first == 'pm')         // robust guard
+        .toList() ??
+        [];
+
+    // Flatten and drop the 'pm' key
+    return pmTags.expand((t) => t.skip(1)).toList();

This keeps the public contract unchanged (List<String>List<String>) while guaranteeing that every declared payment method is surfaced.
If multiple pm tags are indeed impossible, please add a short comment to document that assumption.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1cb3ddb and c8cf737.

📒 Files selected for processing (1)
  • lib/data/models/nostr_event.dart (1 hunks)

Comment on lines +23 to +24
final tag = tags?.firstWhere((t) => t[0] == 'pm', orElse: () => []);
if (tag != null && tag.length > 1) {
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Possible RangeError when a tag is unexpectedly empty

The predicate t[0] == 'pm' assumes every tag contains at least one element. A malformed event with an empty tag ([]) would throw.
Using t.isNotEmpty && t.first == 'pm' (as in the diff above) removes that risk at negligible cost.

🤖 Prompt for AI Agents
In lib/data/models/nostr_event.dart around lines 23 to 24, the code assumes each
tag has at least one element by accessing t[0], which can cause a RangeError if
a tag is empty. To fix this, update the predicate in firstWhere to check that
the tag is not empty before accessing its first element, using t.isNotEmpty &&
t.first == 'pm' to safely avoid the error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion conejito

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grunch ¡Gracias! Me alegra que la sugerencia te resulte útil. Si necesitas que prepare el diff con el ajuste (t.isNotEmpty && t.first == 'pm') o cualquier otra cosa, avísame y con gusto lo planifico. 🐇😊

@Catrya
Copy link
Member

Catrya commented Jun 11, 2025

@AndreaDiazCorreia funciona bien, excepto lo que señaló coderabbit, muestra tm si no hay metodo de pago
image

@grunch
Copy link
Member

grunch commented Jun 11, 2025

@AndreaDiazCorreia funciona bien, excepto lo que señaló coderabbit, muestra tm si no hay metodo de pago image

Genial, gracias catrya, vamos a hacer merge asi, si mostrod sigue el estandar no debe ser necesaria esa validación, gracias andrea

utACK

@grunch grunch merged commit 921772a into MostroP2P:main Jun 11, 2025
1 check passed
@AndreaDiazCorreia AndreaDiazCorreia deleted the fix/issue-115 branch June 14, 2025 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show all payment methods on order cards

3 participants