Skip to content

Commit

Permalink
Always update canPurchase value even if state restored from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
miasma13 committed Apr 25, 2024
1 parent e13e67f commit 8b753bf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions DuckDuckGo/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -750,16 +750,17 @@ extension SettingsViewModel {
// If there's cached data use it by default
if let cachedSubscription = subscriptionStateCache.get() {
state.subscription = cachedSubscription

// Otherwise use defaults and setup purchase availability
} else {
state.subscription = SettingsState.defaults.subscription
state.subscription.canPurchase = SubscriptionPurchaseEnvironment.canPurchase
}

// Update visibility based on Feature flag
state.subscription.enabled = AppDependencyProvider.shared.subscriptionFeatureAvailability.isFeatureAvailable


// Update if can purchase based on App Store product availability
state.subscription.canPurchase = SubscriptionPurchaseEnvironment.canPurchase

// Active subscription check
guard let token = subscriptionAccountManager.accessToken else {
subscriptionStateCache.set(state.subscription) // Sync cache
Expand Down

0 comments on commit 8b753bf

Please sign in to comment.