-
Notifications
You must be signed in to change notification settings - Fork 316
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
GetCustomerInfoAPI
: avoid making a request if there's any PostReceiptDataOperation
in progress
#1911
Conversation
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.
A couple of things but looking good!
let completion: Completion | ||
var cacheKey: String | ||
var source: NetworkOperation.Type | ||
var completion: Completion |
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.
Could we add another init instead of making this mutable? Seems safer to me but lmk if you think there are problems with that.
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.
I'd recommend reading on Swift's value types. This isn't like having mutable data in other languages, it's only mutable for mutables copies, and even then, because it doesn't have reference semantics, you can't have spooky action at a distance by changing one "instance" and mutating something else. So it's perfectly safe.
@aboedo I'll wait for you since this is a pretty critical change and I want to make sure you're ok with it too. |
…iptDataOperation` in progress Fixes [CSDK-419]. This is an improvement over the fix in #1292. In there, we avoided appending on an existing `CustomerInfoOperation` if there were any `PostReceiptDataOperation`s in progress, because those might come back with outdated entitlements. This fix removes that cache key hack, and instead *reuses* the entire response to that `PostReceiptDataOperation` by "stealing" that request's cache key. This is perfectly captured by the existing test `BackendPostReceiptDataTests.testGetsUpdatedSubscriberInfoAfterPost`, added in #1292. Amazingly enough, that test still passes with one minor (:panda:) change: the entire process requires one fewer API call :tada:
2611441
to
f6d9502
Compare
@@ -432,8 +432,7 @@ class BackendPostReceiptDataTests: BaseBackendTests { | |||
|
|||
expect(self.httpClient.calls.map { $0.request.path }) == [ | |||
getCustomerInfoPath, | |||
.postReceiptData, | |||
getCustomerInfoPath |
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.
🐼
**This is an automatic release.** ### New Features * 🚨 `StoreKit 2` is now enabled by default 🚨 (#1922) via NachoSoto (@NachoSoto) * Extracted `PurchasesType` and `PurchasesSwiftType` (#1912) via NachoSoto (@NachoSoto) ### Bugfixes * `StoreKit 1`: changed result of cancelled purchases to be consistent with `StoreKit 2` (#1910) via NachoSoto (@NachoSoto) * `PaymentQueueWrapper`: handle promotional purchase requests from App Store when SK1 is disabled (#1901) via NachoSoto (@NachoSoto) ### Other Changes * Fixed iOS 12 tests (#1936) via NachoSoto (@NachoSoto) * `CacheableNetworkOperation`: fixed race condition in new test (#1932) via NachoSoto (@NachoSoto) * `BasePurchasesTests`: changed default back to SK1 (#1935) via NachoSoto (@NachoSoto) * `Logger`: refactored default `LogLevel` definition (#1934) via NachoSoto (@NachoSoto) * `AppleReceipt`: refactored declarations into nested types (#1933) via NachoSoto (@NachoSoto) * `Integration Tests`: relaunch tests when retrying failures (#1925) via NachoSoto (@NachoSoto) * `CircleCI`: downgraded release jobs to Xcode 13.x (#1927) via NachoSoto (@NachoSoto) * `ErrorUtils`: added test to verify that `PublicError`s can be `catch`'d as `ErrorCode` (#1924) via NachoSoto (@NachoSoto) * `StoreKitIntegrationTests`: print `AppleReceipt` data whenever `verifyEntitlementWentThrough` fails (#1929) via NachoSoto (@NachoSoto) * `OperationQueue`: log debug message when requests are found in cache and skipped (#1926) via NachoSoto (@NachoSoto) * `GetCustomerInfoAPI`: avoid making a request if there's any `PostReceiptDataOperation` in progress (#1911) via NachoSoto (@NachoSoto) * `PurchaseTester`: allow HTTP requests and enable setting `ProxyURL` (#1917) via NachoSoto (@NachoSoto)
Fixes CSDK-419.
This is an improvement over the fix in #1292. In there, we avoided appending on an existing
CustomerInfoOperation
if there were anyPostReceiptDataOperation
s in progress, because those might come back with outdated entitlements.This fix removes that cache key hack, and instead reuses the entire response to that
PostReceiptDataOperation
by "stealing" that request's cache key.This is perfectly captured by the existing test
BackendPostReceiptDataTests.testGetsUpdatedSubscriberInfoAfterPost
, added in #1292. Amazingly enough, that test still passes with one minor change: the entire process requires one fewer API call 🎉 🐼