|
|
@ -23,7 +23,7 @@ enum ViewType { |
|
|
|
class DataStore: NSObject { |
|
|
|
class DataStore: NSObject { |
|
|
|
private static var sharedStore = DataStore(with: UserDefaults.standard) |
|
|
|
private static var sharedStore = DataStore(with: UserDefaults.standard) |
|
|
|
private var userDefaults: UserDefaults! |
|
|
|
private var userDefaults: UserDefaults! |
|
|
|
private var defaultUbiquotousKeyValueStore: NSUbiquitousKeyValueStore! |
|
|
|
private var ubiquitousStore: NSUbiquitousKeyValueStore! |
|
|
|
|
|
|
|
|
|
|
|
// Since these pref can accessed every second, let's cache this |
|
|
|
// Since these pref can accessed every second, let's cache this |
|
|
|
private var shouldDisplayDayInMenubar: Bool = false |
|
|
|
private var shouldDisplayDayInMenubar: Bool = false |
|
|
@ -41,13 +41,13 @@ class DataStore: NSObject { |
|
|
|
init(with defaults: UserDefaults) { |
|
|
|
init(with defaults: UserDefaults) { |
|
|
|
super.init() |
|
|
|
super.init() |
|
|
|
userDefaults = defaults |
|
|
|
userDefaults = defaults |
|
|
|
defaultUbiquotousKeyValueStore = NSUbiquitousKeyValueStore.default |
|
|
|
ubiquitousStore = NSUbiquitousKeyValueStore.default |
|
|
|
shouldDisplayDayInMenubar = shouldDisplay(.dayInMenubar) |
|
|
|
shouldDisplayDayInMenubar = shouldDisplay(.dayInMenubar) |
|
|
|
shouldDisplayDateInMenubar = shouldDisplay(.dateInMenubar) |
|
|
|
shouldDisplayDateInMenubar = shouldDisplay(.dateInMenubar) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func timezones() -> [Data] { |
|
|
|
func timezones() -> [Data] { |
|
|
|
if let cloudPreferences = defaultUbiquotousKeyValueStore.object(forKey: CLDefaultPreferenceKey) as? [Data] { |
|
|
|
if let cloudPreferences = ubiquitousStore.object(forKey: CLDefaultPreferenceKey) as? [Data] { |
|
|
|
Logger.info("Returning preferences from NSUbiquitousKeyValueStore") |
|
|
|
Logger.info("Returning preferences from NSUbiquitousKeyValueStore") |
|
|
|
return cloudPreferences |
|
|
|
return cloudPreferences |
|
|
|
} |
|
|
|
} |
|
|
@ -62,7 +62,7 @@ class DataStore: NSObject { |
|
|
|
func setTimezones(_ timezones: [Data]?) { |
|
|
|
func setTimezones(_ timezones: [Data]?) { |
|
|
|
userDefaults.set(timezones, forKey: CLDefaultPreferenceKey) |
|
|
|
userDefaults.set(timezones, forKey: CLDefaultPreferenceKey) |
|
|
|
// iCloud sync |
|
|
|
// iCloud sync |
|
|
|
defaultUbiquotousKeyValueStore.set(timezones, forKey: CLDefaultPreferenceKey) |
|
|
|
ubiquitousStore.set(timezones, forKey: CLDefaultPreferenceKey) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func menubarTimezones() -> [Data]? { |
|
|
|
func menubarTimezones() -> [Data]? { |
|
|
|