-
Notifications
You must be signed in to change notification settings - Fork 11
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
VPN Waitlist and Debug Menu code cleanup. #3059
VPN Waitlist and Debug Menu code cleanup. #3059
Conversation
@@ -25,7 +25,6 @@ import SwiftUI | |||
|
|||
/// Controller for the VPN debug menu. | |||
/// | |||
@MainActor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raising warnings because NSMenu
is not marked as @MainActor
. I'm removing this because if NSMenu
doesn't need this, our class doesn't either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, there have been other changes recently to move MainActor
off of the class and onto only the functions that need it.
DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionDebugMenu.swift
Show resolved
Hide resolved
private let shouldIncludeAllNetworksMenuItem = NSMenuItem(title: "includeAllNetworks", action: #selector(NetworkProtectionDebugMenu.toggleIncludeAllNetworks)) | ||
private let connectOnLogInMenuItem = NSMenuItem(title: "Connect on Log In", action: #selector(NetworkProtectionDebugMenu.toggleConnectOnLogInAction)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is available in the app settings, not needed in the debug menu.
@objc func toggleExclusionAction(_ sender: NSMenuItem) { | ||
// Temporarily disabled: https://app.asana.com/0/0/1205766100762904/f | ||
/* | ||
guard let addressRange = sender.representedObject as? String else { | ||
assertionFailure("Unexpected representedObject") | ||
return | ||
} | ||
|
||
NetworkProtectionTunnelController().setExcludedRoute(addressRange, enabled: sender.state == .off)*/ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing dead code.
private func populateExclusionsMenuItems() { | ||
excludedRoutesMenu.removeAllItems() | ||
|
||
for item in settings.excludedRoutes { | ||
let menuItem: NSMenuItem | ||
switch item { | ||
case .section(let title): | ||
menuItem = NSMenuItem(title: title, action: nil, target: nil) | ||
menuItem.isEnabled = false | ||
|
||
case .range(let range, let description): | ||
menuItem = NSMenuItem(title: "\(range)\(description != nil ? " (\(description!))" : "")", | ||
action: #selector(toggleExclusionAction), | ||
target: self, | ||
representedObject: range.stringRepresentation) | ||
} | ||
excludedRoutesMenu.addItem(menuItem) | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing dead code.
@objc func resetNetworkProtectionActivationDate(_ sender: Any?) { | ||
overrideNetworkProtectionActivationDate(to: nil) | ||
} | ||
|
||
@objc func overrideNetworkProtectionActivationDateToNow(_ sender: Any?) { | ||
overrideNetworkProtectionActivationDate(to: Date()) | ||
} | ||
|
||
@objc func overrideNetworkProtectionActivationDateTo5DaysAgo(_ sender: Any?) { | ||
overrideNetworkProtectionActivationDate(to: Date.daysAgo(5)) | ||
} | ||
|
||
@objc func overrideNetworkProtectionActivationDateTo10DaysAgo(_ sender: Any?) { | ||
overrideNetworkProtectionActivationDate(to: Date.daysAgo(10)) | ||
} | ||
|
||
private func overrideNetworkProtectionActivationDate(to date: Date?) { | ||
let store = DefaultWaitlistActivationDateStore(source: .netP) | ||
|
||
if let date { | ||
store.updateActivationDate(date) | ||
} else { | ||
store.removeDates() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VPN waitlist is long gone.
func menuNeedsUpdate(_ menu: NSMenu) { | ||
// Temporarily disabled: https://app.asana.com/0/0/1205766100762904/f | ||
/* | ||
if menu === exclusionsMenu { | ||
let controller = NetworkProtectionTunnelController() | ||
for item in menu.items { | ||
guard let route = item.representedObject as? String else { continue } | ||
item.state = controller.isExcludedRouteEnabled(route) ? .on : .off | ||
// TO BE fixed: see NetworkProtectionTunnelController.excludedRoutes() | ||
item.isEnabled = !(controller.shouldEnforceRoutes && route == "10.0.0.0/8") | ||
} | ||
} | ||
*/ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing dead code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall. I'm tempted to suggest removing the Environment
settings as well, since they are permanently greyed out, but I can see the benefit of keeping them for internal users who look there first. I'll leave it up to you.
One thing I noticed during testing is that the Preferred Server menu is never populated with the server list, but that's the case in the main branch too so it's not blocking this.
I opened a task for the list of servers but will move ahead since, as you mention, that issue was not introduced here. Thanks for the review @samsymons ! |
# By Dax the Duck (2) and others # Via Alexey Martemyanov (2) and GitHub (2) * main: Update autoconsent to v10.13.0 (#3063) [DuckPlayer] 1. Move Extension to BSK and add Init Updates (#3055) Bump version to 1.100.0 (238) Bump version to 1.100.0 (237) Improve sorting logic and related test (#3064) VPN Waitlist and Debug Menu code cleanup. (#3059) restore CrashLogMessageExtractor (#3011) # Conflicts: # DuckDuckGo.xcodeproj/project.pbxproj # DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
# By Dax the Duck (8) and others # Via GitHub (5) and Alexey Martemyanov (2) * main: (44 commits) Add RMF `messageShown` attribute (#3062) Update autoconsent to v10.13.0 (#3063) [DuckPlayer] 1. Move Extension to BSK and add Init Updates (#3055) Bump version to 1.100.0 (238) Bump version to 1.100.0 (237) Improve sorting logic and related test (#3064) VPN Waitlist and Debug Menu code cleanup. (#3059) restore CrashLogMessageExtractor (#3011) xattr command removed from the restarting script to avoid the macOS notification (#3057) Duck Player - Improved Settings + Ship Review feedback (#2981) Fix flaky TabContentTests (#3060) PIR Database Migrations: Remove Temporary Internal Time-Based Feature Flag (#3054) Bump version to 1.100.0 (236) Remove unused messaging system (#3047) Automatically add Asana task to macOS App Board (#3053) Disable password generation for burner windows (#3024) PIR: Improve sorting logic and related test (#3049) Remove @mainactor from test case class definitions (#3048) Fix autoplay FF behavior (#3032) Fix ghost InfoPlist.xcstrings (#3044) ... # Conflicts: # DuckDuckGo.xcodeproj/project.pbxproj # DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Task/Issue URL: https://app.asana.com/0/1206580121312550/1207951744290208/f
Description
Cleanup some remaining VPN waitlist code and clean up the debug menu.
Testing
Definition of Done:
Internal references:
Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation