feat: state cards only valid in US - #1426
Conversation
WalkthroughAdjusts merchant activation logic in CTXSpendViewModel, tweaks a gift-card log unit label, adds a “country availability” TextView to the item details layout, and introduces a corresponding string resource. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant UI as UI/View
participant VM as CTXSpendViewModel
participant M as MerchantModel
rect rgba(230,245,255,0.5)
note over VM,M: updateMerchantDetails (new)
UI->>VM: trigger updateMerchantDetails(...)
VM->>VM: evaluate this.enabled, read other fields
VM->>M: set active = this.enabled
VM->>M: set savingsPercentage, minCardPurchase, maxCardPurchase, fixedDenomination, denominations
VM-->>UI: emit updated merchant state
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
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 |
|
@coderabbitai - please review |
|
@HashEngineering I'll review the PR changes for you. 🧠 Learnings used✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
features/exploredash/src/main/res/values/strings-explore-dash.xml (1)
252-252: Copy polish (optional)Consider clearer phrasing: “Gift cards are only valid in the United States.”
- <string name="country_availability">This card works only in the United States</string> + <string name="country_availability">Gift cards are only valid in the United States</string>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt(1 hunks)features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt(1 hunks)features/exploredash/src/main/res/layout/item_details_view.xml(1 hunks)features/exploredash/src/main/res/values/strings-explore-dash.xml(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1417
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/data/explore/MerchantDao.kt:0-0
Timestamp: 2025-08-08T16:48:49.964Z
Learning: In PR dashpay/dash-wallet#1417, HashEngineering chose to defer adding Room indexes for gift_card_providers (provider, denominationsType, merchantId) to a follow-up PR; do not block the current PR on this optimization. Files: features/exploredash/.../data/explore/MerchantDao.kt and features/exploredash/.../data/dashspend/GiftCardProvider.kt.
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1390
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt:129-145
Timestamp: 2025-05-08T18:11:40.249Z
Learning: The hardcoded test data in the purchaseGiftCard() function of CTXSpendViewModel is intentionally left in place for testing the error handling for limit mismatch, and will be fixed later before release.
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1422
File: common/src/main/java/org/dash/wallet/common/util/Constants.kt:68-69
Timestamp: 2025-08-25T15:00:20.777Z
Learning: HashEngineering prefers to keep HTTP logging enabled in release mode (using log.info instead of gating with BuildConfig.DEBUG) to debug production errors, even though this may leak URLs in production logs. This is a deliberate trade-off for debugging purposes in the Dash wallet project.
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1410
File: wallet/src/de/schildbach/wallet/data/InvitationLinkData.kt:79-84
Timestamp: 2025-07-12T07:12:04.769Z
Learning: HashEngineering prefers to handle defensive validation improvements for URI parsing in follow-up PRs rather than including them in the current PR when the main focus is on replacing Firebase with AppsFlyer.
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1423
File: wallet/src/de/schildbach/wallet/ui/EditProfileActivity.kt:418-446
Timestamp: 2025-08-25T14:48:39.247Z
Learning: HashEngineering prefers to refactor and reuse topup code for balance validation logic improvements in DashPay activities like EditProfileActivity, rather than implementing individual fixes in the current PR.
📚 Learning: 2025-05-08T18:11:40.249Z
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1390
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt:129-145
Timestamp: 2025-05-08T18:11:40.249Z
Learning: The hardcoded test data in the purchaseGiftCard() function of CTXSpendViewModel is intentionally left in place for testing the error handling for limit mismatch, and will be fixed later before release.
Applied to files:
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt
📚 Learning: 2025-08-08T16:48:49.964Z
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1417
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/data/explore/MerchantDao.kt:0-0
Timestamp: 2025-08-08T16:48:49.964Z
Learning: In PR dashpay/dash-wallet#1417, HashEngineering chose to defer adding Room indexes for gift_card_providers (provider, denominationsType, merchantId) to a follow-up PR; do not block the current PR on this optimization. Files: features/exploredash/.../data/explore/MerchantDao.kt and features/exploredash/.../data/dashspend/GiftCardProvider.kt.
Applied to files:
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.ktfeatures/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt
🔇 Additional comments (3)
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt (1)
194-196: Unit label now matches seconds; verify analytics expects secondstimeElapsed is already in seconds — confirm downstream dashboards/alerts/ingestion for AnalyticsConstants.Process.PROCESS_GIFT_CARD_PURCHASE expect seconds (not milliseconds).
Location: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt:194-196
Search to run: rg -n -S 'PROCESS_GIFT_CARD_PURCHASE|AnalyticsConstants.Parameter.TIME'features/exploredash/src/main/res/layout/item_details_view.xml (1)
270-281: Make country_availability_text GONE by default and anchor above pay buttonandroid:visibility="visible" shows the US‑only note for all item types; set default to GONE, toggle visibility from code only for the gift‑card flow, and anchor it to the pay button instead of chaining through a view that may be GONE.
File: features/exploredash/src/main/res/layout/item_details_view.xml (lines 270-281)
Apply:
- <TextView + <TextView android:id="@+id/country_availability_text" style="@style/Overline.Secondary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/country_availability" - android:layout_marginBottom="16dp" - android:visibility="visible" + android:layout_marginBottom="16dp" + android:visibility="gone" + tools:visibility="visible" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintBottom_toTopOf="@id/temporary_unavailable_text" + app:layout_constraintBottom_toTopOf="@id/pay_btn" />Confirm visibility is toggled from code only when the gift‑card flow is available and that @id/pay_btn exists (sandbox search returned no results; manual verification required).
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt (1)
229-231: Activation logic change risks hiding fixed‑denomination merchants — verify or revertFile: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt (lines 229–231)
merchant.active is now set to only this.enabled; merchant.active is used to gate purchase/visibility (PurchaseGiftCardFragment, ItemDetails, SearchFragment and explore filters/tests). As written, fixed‑denomination merchants may be hidden when the API returns enabled == false.
Apply if revert is desired:
- merchant.active = this.enabled + merchant.active = this.enabled || this.denominationType == DenominationType.Fixed
…feat/dashspend-mark-country
Issue being fixed or feature implemented
add a note that says gift cards are only valid in the United States.
Related PR's and Dependencies
Screenshots / Videos
How Has This Been Tested?
Checklist:
Summary by CodeRabbit