-
Notifications
You must be signed in to change notification settings - Fork 16
Modularize debug menu and login items logic #1378
Conversation
DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionTunnelController.swift
Show resolved
Hide resolved
DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionTunnelController.swift
Show resolved
Hide resolved
graeme
left a comment
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.
A few comments. Nothing blocking, mainly cosmetic. If you do change anything else and want me to have another look, gimme a shout.
DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionLoginItemsManager.swift
Outdated
Show resolved
Hide resolved
DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionLoginItemsManager.swift
Outdated
Show resolved
Hide resolved
...uckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionDebugMenuController.swift
Outdated
Show resolved
Hide resolved
mallexxx
left a comment
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.
I like the changes, that‘s so much cleaner! 🥳 See some comments inline
...uckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionDebugMenuController.swift
Outdated
Show resolved
Hide resolved
...uckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionDebugMenuController.swift
Outdated
Show resolved
Hide resolved
|
For history and context: the remaining feedback is addressed in a follow up PR here: #1389 |
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.
#if NETWORK_PROTECTION import NetworkProtection #endif can now be removed
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.
Removed.
| /// Controller for the Network Protection debug menu. | ||
| /// | ||
| @objc | ||
| final class NetworkProtectionDebugMenuController: NSObject { |
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.
In other places menu items are managed by subclassing NSMenu (ApplicationDockMenu, MainMenu, HistoryMenu, MoreoptionsMenu, SharingMenu etc..)
Let‘s convert this into : NSMenu subclass - this will remove the need of an extra object in MainMenu, networkProtectionMenuItem and networkProtectionDebugMenuController outlets
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.
we could also use self.supermenu()?.remove(at: self.supermenu()!.indexOfItem(withSubmenu: self)) in awakeFromNib() inside the !NETWORK_PROTECTION block to remove the menu management code from MainMenu - not strong on this
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.
Addressed in #1397
|
|
||
| // MARK: - Registration Key Validity | ||
|
|
||
| static let registrationKeyValidityKey = "com.duckduckgo.network-protection.NetworkProtectionTunnelController.registrationKeyValidityKey" |
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.
Can this be replaced with @UserDefaultsWrapper?
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.
Addressed in #1397
| /// - validity: the default registration key validity time interval. A `nil` value means it will be automatically | ||
| /// defined by NetP using its standard configuration. | ||
| /// | ||
| func setRegistrationKeyValidity(_ validity: TimeInterval?, defaults: UserDefaults = .standard) async throws { |
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 call is raising "Non-sendable type 'UserDefaults' exiting main actor-isolated context in call to non-isolated instance method 'setRegistrationKeyValidity(_:defaults:)' cannot cross actor boundary" warning in NetworkProtectionDebugMenuController - could we use @UserDefaultsWrapper instead of direct UserDefaults passing here?
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.
Addressed in #1397
| /// Sets the selected server. | ||
| /// | ||
| @IBAction | ||
| func setSelectedServer(_ sender: Any?) { |
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.
NSMenuItem sender type can be directly set in the definition instead of casting - not something critical but reduces unneeded 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.
Yeah I don't mind either way but the reason I don't worry too much about these is that the guard below is staying, just in a slightly different form.
Either way I'm pushing this change since the guard becomes slightly nicer to read.
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.
I mean we could get rid of the guard statement entirely by making the sender argument non- optional since it isn't meant to be called from outside
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.
Addressed in #1397
| if menuItem.state == .on { | ||
| menuItem.state = .off | ||
| } else { | ||
| menuItem.state = .on | ||
| } |
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 should be set in the update() method - item state is not reset after the simulationOptions is reset
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.
Tackled in #1397
| if menuItem.state == .on { | ||
| menuItem.state = .off | ||
| } else { | ||
| menuItem.state = .on | ||
| } |
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.
same as above
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.
Tackled in #1397
| @IBOutlet weak var networkProtectionMenuItem: NSMenuItem? | ||
| @IBOutlet weak var networkProtectionMenuItem: NSMenuItem? { | ||
| didSet { | ||
| networkProtectionMenuItem?.target = networkProtectionDebugMenuController |
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.
why is it needed?
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.
It's actually not - I think it was necessary at some point when the code was mostly living here, but after moving it I lost track of coming back to remove this. Good catch.
| <scene sceneID="JPo-4y-FX3"> | ||
| <objects> | ||
| <customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target"/> | ||
| <customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/> |
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.
not related but since you‘re touching it, could you remove an empty Menu object from the storyboard? It seemingly got there by mistake and not used anywhere
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.
Tackled in #1397
| func ensureLoginItemsAreRunning(_ condition: LoginItemCheckCondition = .none, after interval: TimeInterval = .seconds(5)) { | ||
|
|
||
| Task { | ||
| try? await Task.sleep(interval: interval) |
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.
thrown error shouldn‘t be ignored for Task.sleep (meaning cancellation)
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.
Tackled in #1397
Task/Issue URL: https://app.asana.com/0/0/1205135296966627/f This is a follow up to: #1378 ## Stack: - #1378 - #1389 <- This PR ## Description: Implements some changes based on the feedback received in these two comments: - #1378 (comment) - #1378 (comment) These changes were tackled separately for these reasons: - The base PR was mostly about moving existing code to a different location. - The base PR works fine. - Reviewing these changes separately guarantees a faster and more focused feedback loop.
|
@diegoreymendez, not really huge 🤷♂️ especially having #1397 based on |
|
@mallexxx - Part of the issue is that this PR's scope exploded, and I should've pushed back on it. A lot of the requested changes in this review are really out of scope. I'll bring this up for discussion separately as a PR is probably not the best place for it. |
|
I'm merging as the issues I'm seeing in CI have absolutely nothing to do with my changes. |
Task/Issue URL: https://app.asana.com/0/1199230911884351/1205144339578924/f ## Stack: - #1378 - #1389 - #1397 <- This PR ## Description: Addresses some feedback in the base PR: - #1378 (comment) - #1378 (comment) - #1378 (comment) - #1378 (comment) - #1378 (comment) - #1378 (comment) - #1378 (comment)
# By Dominik Kapusta (7) and others # Via Sam Symons (2) and others * develop: Modularize debug menu and login items logic #3 (#1397) Modularize debug menu and login items logic (#1378) Fixes of minor issues with Fire Button after the new logic release (#1395) Fire Window (#1357) Fix reordering favorites in the last row when it's not fully populated (#1401) Close the window when cmd+w is pressed on a pinned tab and there are no regular tabs (#1390) update sparkle to 2.4.2 (#1362) disable trailing_comma (#1394) Add support for per-model Sync Data Providers initialization (#1387) update favicon logic to fix gsuite icons (#1380) Update minor version by default in code_freeze lane (#1392) Upload dSYMs from release builds to S3 for Sentry (#1393) Set version to 1.48.2. Hide Cards UI on macOS Catalina (#1386) Hide Cards UI on macOS Catalina (#1386) update shield icon only after navigation ended and tab is selected (#1314) Add Debug menu option back in for resetting the Email Protection InContext prompt (#1373) Bump version to 1.49.0 (42) Update embedded files # Conflicts: # DuckDuckGo.xcodeproj/project.pbxproj # DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Task/Issue URL: https://app.asana.com/0/0/1205112155849082/f
Stack:
Description
This PR:
NetworkProtectionTunnelProviderinto its own class.This will have the following advantages:
NetworkProtectionTunnelProvidermeans we're closer to being able to share it with iOS, which IMHO would be great many ways.Testing
Test 1: Debug Menu
Test the debug menu and make sure all works well.
Test 2: Login Items
Internal references:
Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation