Skip to content
This repository has been archived by the owner on Feb 24, 2025. It is now read-only.

Enabled always-on by default #2043

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/UserDefaultsPropertyWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public struct UserDefaultsWrapper<T> {

case syncEnvironment = "com.duckduckgo.ios.sync-environment"

case networkProtectionDebugOptionAlwaysOnEnabled = "com.duckduckgo.network-protection.always-on.enabled"
case networkProtectionDebugOptionAlwaysOnDisabled = "com.duckduckgo.network-protection.always-on.disabled"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing the user default so that it will be ON by default for existing users. In any case the change makes sense IMO since the default is now going to be ON, so the presence of this will most likely indicate that the user disabled always on.

}

private let key: Key
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/NetworkProtectionDebugFeatures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ import Foundation
import Core

final class NetworkProtectionDebugFeatures {
@UserDefaultsWrapper(key: .networkProtectionDebugOptionAlwaysOnEnabled, defaultValue: false)
var alwaysOnEnabled
@UserDefaultsWrapper(key: .networkProtectionDebugOptionAlwaysOnDisabled, defaultValue: false)
var alwaysOnDisabled
}
16 changes: 8 additions & 8 deletions DuckDuckGo/NetworkProtectionDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class NetworkProtectionDebugViewController: UITableViewController {
}

enum DebugFeatureRows: Int, CaseIterable {
case enableAlwaysOn
case toggleAlwaysOn
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This case is really for toggling always on, not enabling it.

}

enum SimulateFailureRows: Int, CaseIterable {
Expand Down Expand Up @@ -191,13 +191,13 @@ final class NetworkProtectionDebugViewController: UITableViewController {

private func configure(_ cell: UITableViewCell, forDebugFeatureAtRow row: Int) {
switch DebugFeatureRows(rawValue: row) {
case .enableAlwaysOn:
cell.textLabel?.text = "Enable Always On"
case .toggleAlwaysOn:
cell.textLabel?.text = "Always On"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the name since the tick in the debug menu options indicates whether this is ON or OFF.


if debugFeatures.alwaysOnEnabled {
cell.accessoryType = .checkmark
} else {
if debugFeatures.alwaysOnDisabled {
cell.accessoryType = .none
} else {
cell.accessoryType = .checkmark
}
default:
break
Expand All @@ -206,8 +206,8 @@ final class NetworkProtectionDebugViewController: UITableViewController {

private func didSelectDebugFeature(at indexPath: IndexPath) {
switch DebugFeatureRows(rawValue: indexPath.row) {
case .enableAlwaysOn:
debugFeatures.alwaysOnEnabled.toggle()
case .toggleAlwaysOn:
debugFeatures.alwaysOnDisabled.toggle()
tableView.reloadRows(at: [indexPath], with: .none)
default:
break
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/NetworkProtectionTunnelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final class NetworkProtectionTunnelController: TunnelController {
throw error
}

if debugFeatures.alwaysOnEnabled {
if !debugFeatures.alwaysOnDisabled {
Task {
try await enableOnDemand(tunnelManager: tunnelManager)
}
Expand Down