-
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
Update offerings cache when switchUser(to:) is called #2455
Conversation
Logger.debug(Strings.identity.switching_user(newUserId: newAppUserID)) | ||
Logger.debug(Strings.identity.switching_user(newUserID: newAppUserID)) |
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.
renamed param for consistency with others
guard self.identityManager.currentAppUserID != newAppUserID else { | ||
self.logger.warn(Strings.identity.switching_user_same_app_user_id(newUserID: newAppUserID)) | ||
return | ||
} |
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.
we missed this in the original implementation but it becomes a lot more important when a cache update is added to the mix
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.
👍🏻
func testRefreshesOfferingsCache() { | ||
expect(self.mockOfferingsManager.invokedUpdateOfferingsCacheCount) == 0 | ||
|
||
self.systemInfo = MockSystemInfo(finishTransactions: true, customEntitlementsComputation: true) |
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 initialization is duplicated in several tests now, might be worth extracting.
} | ||
|
||
func testSwitchUserNoOpIfAppUserIDIsSameAsCurrent() { | ||
self.systemInfo = MockSystemInfo(finishTransactions: true, customEntitlementsComputation: true) |
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.
Ditto duplicated initialization.
@NachoSoto I ended up going with a slightly simpler path. And... I think we might wanna do this a bit more tbh, it feels a lot simpler to manage. |
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.
Great idea! I like the simple approach. I think tests should catch that this is backwards though :)
|
||
#if !ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION |
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 think this is backwards?
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.
LOL I shouldn't be allowed to code. Or at least not automerge
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.
fixed
Oh they don't yet because APITesters aren't merged. |
I disabled auto merge just in case. |
/// | ||
/// Updates the current appUserID to a new one, without associating the two. | ||
/// - Important: This method is **only available** in Custom Entitlements Computation mode. | ||
/// Receipts posted by the SDK to the RevenueCat backend after calling this method will be sent | ||
/// with the newAppUserID. | ||
/// | ||
@objc(switchUserToNewAppUserID:) | ||
func switchUser(to newAppUserID: String) { | ||
public func switchUser(to newAppUserID: String) { | ||
internalSwitchUser(to: newAppUserID) |
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.
Nit:
internalSwitchUser(to: newAppUserID) | |
self.internalSwitchUser(to: newAppUserID) |
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.
oh, woops, forgot
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.
added
@NachoSoto thanks for the catches! Updated |
440123a
to
6e41333
Compare
Added updating of offerings cache when `switchUser(to:)` is called. Also added checking that the new appUserID != the current one and no-op if it is.
Added updating of offerings cache when
switchUser(to:)
is called.Also added checking that the new appUserID != the current one and no-op if it is.