refactor(apple): Only apply MDM config when changed (#9173)

In #9169 we applied MDM configuration from MDM upon _any_ change to
UserDefaults. This is unnecessary.

Instead, we can compare new vs old and only apply the new dict if
there's changes.

In this PR we also log the old and new dicts for debugging reasons.
This commit is contained in:
Jamil
2025-05-16 16:21:08 -07:00
committed by GitHub
parent ca59492003
commit e14c4e1eb8

View File

@@ -81,7 +81,15 @@ class ConfigurationManager {
}
@objc private func handleUserDefaultsChanged(_ notification: Notification) {
self.managedDict = userDefaults.dictionary(forKey: managedDictKey) ?? [:]
let newManagedDict = (userDefaults.dictionary(forKey: managedDictKey) ?? [:]) as [String: Any?]
// NSDictionary conforms to Equatable
if (managedDict as NSDictionary) == (newManagedDict as NSDictionary) {
return
}
Log.log("Applying MDM configuration. Old: \(managedDict) New: \(newManagedDict)")
self.managedDict = newManagedDict
}
private func saveUserDict() {