Skip to content
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

Merged
merged 8 commits into from
Mar 21, 2024

Conversation

miasma13
Copy link
Contributor

@miasma13 miasma13 commented Mar 21, 2024

Task/Issue URL: https://app.asana.com/0/1199230911884351/1206896697354395/f

Description:

  • when closing DBP tab on subscription account sign out make it on main thread
  • update cached subscription and entitlements on app launch
  • hide "View Plans" button on expired subscription state as it is not fully handled
  • more coherent refresh of subscription settings

Internal references:

Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation

@miasma13 miasma13 changed the title Michal/tweaks and fixes Bug fixes for updating subscription staet Mar 21, 2024
@miasma13 miasma13 changed the title Bug fixes for updating subscription staet Bug fixes for refreshing and updating subscription state Mar 21, 2024
@github-actions github-actions bot added bot: not in app board Added by automation for pull requests with tasks not added to macOS App Board Asana project and removed bot: not in app board Added by automation for pull requests with tasks not added to macOS App Board Asana project labels Mar 21, 2024
Copy link
Member

@federicocappelli federicocappelli left a 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)
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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 {}

Copy link
Contributor Author

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.

@miasma13 miasma13 merged commit e7d0897 into main Mar 21, 2024
32 of 33 checks passed
@miasma13 miasma13 deleted the michal/tweaks-and-fixes branch March 21, 2024 15:35
samsymons added a commit that referenced this pull request Mar 21, 2024
* main:
  Bug fixes for refreshing and updating subscription state (#2473)
  Add additional parameters to breakage reports (#2416)
  Main thread issue for NetworkProtection nav bar icon update (#2466)
  Update the last version run store usage (#2441)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants