Browse Source

Inject Data Store + Defaults in AppDefaults.swift

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
f6032a8439
  1. 21
      Clocker/Overall App/AppDefaults.swift

21
Clocker/Overall App/AppDefaults.swift

@ -4,25 +4,22 @@ import Cocoa
import CoreLoggerKit
class AppDefaults {
class func initialize() {
initializeDefaults()
class func initialize(with store: DataStore, defaults: UserDefaults) {
initializeDefaults(with: store, defaults: defaults)
}
private class func initializeDefaults() {
let userDefaults = UserDefaults.standard
let dataStore = DataStore.shared()
let timezones = dataStore.timezones()
let selectedCalendars = userDefaults.object(forKey: CLSelectedCalendars)
private class func initializeDefaults(with store: DataStore, defaults: UserDefaults) {
let timezones = store.timezones()
let selectedCalendars = defaults.object(forKey: CLSelectedCalendars)
// Register the usual suspects
userDefaults.register(defaults: defaultsDictionary())
defaults.register(defaults: defaultsDictionary())
dataStore.setTimezones(timezones)
userDefaults.set(selectedCalendars, forKey: CLSelectedCalendars)
store.setTimezones(timezones)
defaults.set(selectedCalendars, forKey: CLSelectedCalendars)
// Set the theme default as Light!
setDefaultTheme(userDefaults)
setDefaultTheme(defaults)
}
private class func setDefaultTheme(_ userDefaults: UserDefaults) {

Loading…
Cancel
Save