-
Notifications
You must be signed in to change notification settings - Fork 11
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
Bug fixes for refreshing and updating subscription state #2473
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.
I don't have any blocker, just some coding suggestions, but I need to be honest, I don't understand many of the changes.
case .failure: | ||
self.hasAccessToITR = false | ||
} | ||
await self.updateSubscription(with: .returnCacheDataElseLoad) |
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 it ok for an init to have side effects like this one? I would generally avoid running operations in a function that is supposed to just initialise an object.
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 understand, the problem here was that those calls are used to setup the initial state of the VM but since they are async. I agree that it is smelly and screams for improvement.
|
||
let subscriptionResult = await SubscriptionService.getSubscription(accessToken: token, cachePolicy: .reloadIgnoringLocalCacheData) | ||
@MainActor |
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 have noticed the general approach to wrapping everything in @mainactor, but I don't see anything in this function that demands to be executed on the main thread. If any of the called function is @mainactor on it's own I would suggest to wrap in in a DisapatchQueue.main.async {}
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.
These actually were required since during runtime I got SwiftUI warnings about publishing changes not from main thread.
Task/Issue URL: https://app.asana.com/0/1199230911884351/1206896697354395/f
Description:
Internal references:
Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation