Skip to content

Commit

Permalink
Properly reflect state + default to staging in alpha/debug
Browse files Browse the repository at this point in the history
  • Loading branch information
afterxleep committed Apr 23, 2024
1 parent 10c7aab commit d7dab93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

private func setupSubscriptionsEnvironment() {
Task {
let environment = SubscriptionPurchaseEnvironment.ServiceEnvironment(rawValue: privacyProEnvironment) ??
SubscriptionPurchaseEnvironment.ServiceEnvironment.default
#if ALPHA || DEBUG
let defaultEnvironment = SubscriptionPurchaseEnvironment.ServiceEnvironment.staging
#else
let defaultEnvironment = SubscriptionPurchaseEnvironment.ServiceEnvironment.production
#endif
let environment = SubscriptionPurchaseEnvironment.ServiceEnvironment(rawValue: privacyProEnvironment) ?? defaultEnvironment
SubscriptionPurchaseEnvironment.currentServiceEnvironment = environment
VPNSettings(defaults: .networkProtectionGroupDefaults).selectedEnvironment = (environment == .production) ? .production : .staging
SubscriptionPurchaseEnvironment.current = .appStore
Expand Down
8 changes: 4 additions & 4 deletions DuckDuckGo/SubscriptionDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ final class SubscriptionDebugViewController: UITableViewController {
}

case .environment:
let staging = SubscriptionPurchaseEnvironment.ServiceEnvironment.staging.rawValue
let prod = SubscriptionPurchaseEnvironment.ServiceEnvironment.production.rawValue
let staging = SubscriptionPurchaseEnvironment.ServiceEnvironment.staging
let prod = SubscriptionPurchaseEnvironment.ServiceEnvironment.production
switch EnvironmentRows(rawValue: indexPath.row) {
case .staging:
cell.textLabel?.text = "Staging"
cell.accessoryType = privacyProEnvironment == staging ? .checkmark : .none
cell.accessoryType = SubscriptionPurchaseEnvironment.currentServiceEnvironment == staging ? .checkmark : .none
case .production:
cell.textLabel?.text = "Production"
cell.accessoryType = privacyProEnvironment == prod ? .checkmark : .none
cell.accessoryType = SubscriptionPurchaseEnvironment.currentServiceEnvironment == prod ? .checkmark : .none
case .none:
break
}
Expand Down

0 comments on commit d7dab93

Please sign in to comment.