fix(useIAP): forward PurchaseOptions in getAvailablePurchases and res…#3173
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe changes extend the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3173 +/- ##
==========================================
+ Coverage 68.97% 69.07% +0.10%
==========================================
Files 9 9
Lines 1792 1798 +6
Branches 585 589 +4
==========================================
+ Hits 1236 1242 +6
Misses 551 551
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request refactors the getAvailablePurchases and restorePurchases methods within the useIAP hook to accept a PurchaseOptions object, allowing for more configurable behavior. The getAvailablePurchasesInternal function has been updated to utilize these options. However, an inconsistency was noted where the restorePurchasesTopLevel function, called by the hook's restorePurchases, does not yet accept PurchaseOptions, potentially leading to hardcoded options being used in its internal getAvailablePurchases call, while the hook's subsequent call uses the provided options. It is suggested to update restorePurchases in src/index.ts to also accept and forward PurchaseOptions for full consistency.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/hooks/useIAP.ts`:
- Around line 275-282: The Android Nitro calls inside getAvailablePurchases (and
the path used by restorePurchases via getAvailablePurchasesInternal) currently
hardcode android options and omit the includeSuspended flag; update the
construction of the Nitro Android options (where { android: { type: 'inapp' } }
/ { android: { type: 'subs' } } is created) to include includeSuspended:
options?.includeSuspendedAndroid ?? false (matching the
NitroAvailablePurchasesAndroidOptions field name), and ensure
getAvailablePurchasesInternal/restorePurchases forwards the same options object
so the Android includeSuspended flag is passed through to Nitro.
- Around line 67-68: getAvailablePurchases is accepting includeSuspendedAndroid
in PurchaseOptions but the Android path in the IAP calls doesn't forward it to
the Nitro layer; update the calls that call IAP.instance.getAvailablePurchases
(for both inapp and subs) to pass an android object with includeSuspended set
from options?.includeSuspendedAndroid ?? false (and keep android.type as 'inapp'
or 'subs') so the NitroAvailablePurchasesAndroidOptions.includeSuspended field
is populated.
…torePurchases The hook's getAvailablePurchases and restorePurchases methods were hardcoding PurchaseOptions (alsoPublishToEventListenerIOS, onlyIncludeActiveItemsIOS), making it impossible for hook consumers to customize these values. This change adds an optional PurchaseOptions parameter to both methods, defaulting to the previous behavior for backward compatibility. Related to hyochan/expo-iap#329
- Replace restorePurchasesTopLevel with direct syncIOS call to eliminate redundant getAvailablePurchases network request - Forward includeSuspendedAndroid to Android Nitro calls in getAvailablePurchases - Update tests for new syncIOS mock and Android includeSuspended param Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c08b5df to
4a39287
Compare
…torePurchases
The hook's getAvailablePurchases and restorePurchases methods were hardcoding PurchaseOptions (alsoPublishToEventListenerIOS, onlyIncludeActiveItemsIOS), making it impossible for hook consumers to customize these values.
This change adds an optional PurchaseOptions parameter to both methods, defaulting to the previous behavior for backward compatibility.
Related to hyochan/expo-iap#329
Summary by CodeRabbit
Release Notes