-
Notifications
You must be signed in to change notification settings - Fork 382
Refetch offerings when preferred locale is set #5511
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
Conversation
1e1d72c
to
c8ff9b7
Compare
📸 Snapshot Test2 modified, 691 unchanged
🛸 Powered by Emerge Tools |
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.
Nice addition! This is something we discussed about whether or not to add precisely to avoid too many requests. But the rate limiter does solve it 👌
Before approving though, I have a small suggestion.
if self.overridePreferredUILocaleRateLimiter.shouldProceed() { | ||
// Refetches new offerings with preferred locale | ||
self.getOfferings(fetchPolicy: .default, fetchCurrent: true) { _, _ in | ||
// No-op | ||
} | ||
} |
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.
Perhaps we could trigger the getOfferings
only when
self.systemInfo.preferredLocaleOverride != locale
It's the most basic comparison, but at least it guards against developers setting to the already-set preferred locale.
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 rather bump that responsibility to the networking layer, but I see that we are using an ephemeral session with no cache. And our e-tag cache isn't well suited for this… is there a reason we can't inject a flag to a request to use a non ephemeral session and set the cache policy to something really short like a minute?
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.
Is there a reason we can't inject a flag to a request to use a non ephemeral session and set the cache policy to something really short like a minute?
This is a question 🤔 I'm do not remember off the top of my head why we use the session and caching that we use. I used to know at one point but probably should understand again 🤷♂️
I'd rather bump that responsibility to the networking layer
I'll leave it here for now since it short circuits it right at the start without touching any other layers and so its explicit that we aren't doing any extra networking calls to our API
Motivation
Refetch current offerings (no cache) when preferred locale is set
Description
Use a rate limiter when attempting to fetch current offerings when setting preferred locale (2 times per minute)