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

Clean up subscription state caching in settings logic #2925

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

miasma13
Copy link
Contributor

@miasma13 miasma13 commented Jun 6, 2024

Task/Issue URL: https://app.asana.com/0/414709148257752/1207502776093446/f

Description:
To reduce the amount of network traffic when opening settings the subscription section state is being cached for immediate view state initialisation and then various state properties are being refreshed. Inspecting the code it turns out that in some of the scenarios of for example connectivity failure, cache expiry and/or access token missing the cached state may be outdated or wrong.

Steps to test this PR:
Review the logic check and confirm entitlements array is replaced not appended:

  1. Purchase or activate subscription
  2. Wait for the subscription service cache expiry (20m) or change the code for force reload by replacing:
    let subscriptionResult = await subscriptionManager.subscriptionService.getSubscription(accessToken: token) with
    let subscriptionResult = await subscriptionManager.subscriptionService.getSubscription(accessToken: token, cachePolicy: .reloadIgnoringLocalCacheData)
  3. Inspect state.subscription for the entitlements array at the end of setupSubscriptionEnvironment()

Internal references:

Software Engineering Expectations
Technical Design Template

@miasma13 miasma13 requested a review from samsymons June 6, 2024 20:39
@miasma13 miasma13 changed the base branch from main to release/7.123.0 June 6, 2024 20:40
Copy link
Contributor

@samsymons samsymons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested with the instructions and everything looked good. I did a general smoke test of other Privacy Pro behaviour without any issues as well.

@samsymons samsymons merged commit 9f87e34 into release/7.123.0 Jun 6, 2024
24 checks passed
@samsymons samsymons deleted the michal/fix-subscription-state-cache branch June 6, 2024 22:36
samsymons added a commit that referenced this pull request Jun 7, 2024
* main: (34 commits)
  Release 7.122.1-0 (#2932)
  Fix widgets init due to crash of availability check inside builder on iOS 16 (#2931)
  Show subscription settings section either when subscription purchase is possible or user is authenticated (#2922)
  Release 7.123.0-1 (#2928)
  Do not refresh UI only if AutoClear was triggered (#2924)
  Do not refresh UI only if AutoClear was triggered (#2924)
  Clean up subscription state caching in settings logic (#2925)
  Force Omni Bar cancellation when submitting a query (#2923)
  Hide 'Set your address bar position' for iPad (#2913)
  Select correct access group for SubscriptionTokenKeychainStorage (#2918)
  Remove VPN waitlist feature flags and access controller (#2919)
  Remove usage of token store from iOS VPN (#2892)
  Update autoconsent to v10.9.0 (#2908)
  Load child Privacy Pro views lazily (#2917)
  Surface specific XPC & login item errors on macOS (#2872)
  Removing the temporary password manager survey code (#2910)
  Release 7.123.0-0 (#2915)
  Use better wording for history autocomplete description (#2914)
  Additional Privacy Pro RMF changes (#2911)
  Bump BSK - No iOS Changes, Enables macOS DBP Changes (#2877)
  ...
samsymons added a commit that referenced this pull request Jun 9, 2024
# By Michal Smaga (6) and others
# Via Michal Smaga (3) and GitHub (1)
* main:
  DBP: Bump C-S-S version to 5.19.0 (#2927)
  Release 7.123.0-2 (#2933)
  Fix widgets init due to crash of availability check inside builder on iOS 16 (#2931)
  Release 7.122.1-0 (#2932)
  Fix widgets init due to crash of availability check inside builder on iOS 16 (#2931)
  Show subscription settings section either when subscription purchase is possible or user is authenticated (#2922)
  Release 7.123.0-1 (#2928)
  Do not refresh UI only if AutoClear was triggered (#2924)
  Clean up subscription state caching in settings logic (#2925)
  Force Omni Bar cancellation when submitting a query (#2923)
  Remove Privacy Pro line from release notes (#2902)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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