Skip to content

Commit

Permalink
attempt to check for MDM profile changes
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Jul 2, 2024
1 parent d7fe24f commit 0fb6fbe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ Requires macOS 12.0 and higher. Further releases and feature requests may make t
- Nudge can now attempt to honor DoNotDisturb/Focus times
- To enable this, please configure the `honorFocusModes` key in `optionalFeatures` to true
- This is an **expiremental feature** and may not work due to significant changes that Apple has designed for detecting these events.
- Nudge now attempts to reload the preferences if MDM profile is updated
- Issue [370](https://github.com/macadmins/nudge/issues/370)

## [1.1.16] - 2024-03-13
This will be the **final Nudge release** for macOS 11 and potentially other versions of macOS.
Expand Down
2 changes: 1 addition & 1 deletion Nudge/UI/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct Globals {
static let snc = NSWorkspace.shared.notificationCenter
// Preferences
static let configJSON = ConfigurationManager().getConfigurationAsJSON()
static let configProfile = ConfigurationManager().getConfigurationAsProfile()
static var configProfile = ConfigurationManager().getConfigurationAsProfile()
static let nudgeDefaults = UserDefaults.standard
static let nudgeJSONPreferences = NetworkFileManager().getNudgeJSONPreferences()
// Device Properties
Expand Down
10 changes: 10 additions & 0 deletions Nudge/UI/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
setupScreenChangeObservers()
setupScreenLockObservers()
setupWorkspaceNotificationCenterObservers()
setupUserDefaultsObservers()
}

private func setupNotificationCenterObservers() {
Expand All @@ -619,6 +620,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

private func setupUserDefaultsObservers() {
Globals.nc.addObserver(
forName: UserDefaults.didChangeNotification,
object: nil,
queue: .main) { [weak self] _ in
Globals.configProfile = ConfigurationManager().getConfigurationAsProfile()
}
}

private func setupScreenChangeObservers() {
Globals.nc.addObserver(
self,
Expand Down

0 comments on commit 0fb6fbe

Please sign in to comment.