|
|
@ -15,9 +15,6 @@ class AppDefaults { |
|
|
|
let timezones = dataStore.timezones() |
|
|
|
let timezones = dataStore.timezones() |
|
|
|
let selectedCalendars = userDefaults.object(forKey: CLSelectedCalendars) |
|
|
|
let selectedCalendars = userDefaults.object(forKey: CLSelectedCalendars) |
|
|
|
|
|
|
|
|
|
|
|
// Now delete the old preferences |
|
|
|
|
|
|
|
userDefaults.wipeIfNeccesary() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Register the usual suspects |
|
|
|
// Register the usual suspects |
|
|
|
userDefaults.register(defaults: defaultsDictionary()) |
|
|
|
userDefaults.register(defaults: defaultsDictionary()) |
|
|
|
|
|
|
|
|
|
|
@ -25,13 +22,11 @@ class AppDefaults { |
|
|
|
userDefaults.set(selectedCalendars, forKey: CLSelectedCalendars) |
|
|
|
userDefaults.set(selectedCalendars, forKey: CLSelectedCalendars) |
|
|
|
|
|
|
|
|
|
|
|
// Set the theme default as Light! |
|
|
|
// Set the theme default as Light! |
|
|
|
setDefaultTheme() |
|
|
|
setDefaultTheme(userDefaults) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class func setDefaultTheme() { |
|
|
|
private class func setDefaultTheme(_ userDefaults: UserDefaults) { |
|
|
|
let defaults = UserDefaults.standard |
|
|
|
if userDefaults.object(forKey: CLThemeKey) == nil { |
|
|
|
|
|
|
|
|
|
|
|
if defaults.object(forKey: CLThemeKey) == nil { |
|
|
|
|
|
|
|
Themer.shared().set(theme: 0) |
|
|
|
Themer.shared().set(theme: 0) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -67,17 +62,7 @@ extension String { |
|
|
|
|
|
|
|
|
|
|
|
extension UserDefaults { |
|
|
|
extension UserDefaults { |
|
|
|
// Use this with caution. Exposing this for debugging purposes only. |
|
|
|
// Use this with caution. Exposing this for debugging purposes only. |
|
|
|
func wipe() { |
|
|
|
func wipe(for bundleID: String) { |
|
|
|
if let bundleID = Bundle.main.bundleIdentifier { |
|
|
|
removePersistentDomain(forName: bundleID) |
|
|
|
removePersistentDomain(forName: bundleID) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func wipeIfNeccesary() { |
|
|
|
|
|
|
|
if object(forKey: "PreferencesHaveBeenWiped") == nil { |
|
|
|
|
|
|
|
Logger.info("Wiping all user defaults") |
|
|
|
|
|
|
|
wipe() |
|
|
|
|
|
|
|
set(true, forKey: "PreferencesHaveBeenWiped") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|