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 import CoreLoggerKit
class AppDefaults { class AppDefaults {
class func initialize() { class func initialize(with store: DataStore, defaults: UserDefaults) {
initializeDefaults() initializeDefaults(with: store, defaults: defaults)
} }
private class func initializeDefaults() { private class func initializeDefaults(with store: DataStore, defaults: UserDefaults) {
let userDefaults = UserDefaults.standard let timezones = store.timezones()
let dataStore = DataStore.shared() let selectedCalendars = defaults.object(forKey: CLSelectedCalendars)
let timezones = dataStore.timezones()
let selectedCalendars = userDefaults.object(forKey: CLSelectedCalendars)
// Register the usual suspects // Register the usual suspects
userDefaults.register(defaults: defaultsDictionary()) defaults.register(defaults: defaultsDictionary())
dataStore.setTimezones(timezones) store.setTimezones(timezones)
userDefaults.set(selectedCalendars, forKey: CLSelectedCalendars) defaults.set(selectedCalendars, forKey: CLSelectedCalendars)
// Set the theme default as Light! // Set the theme default as Light!
setDefaultTheme(userDefaults) setDefaultTheme(defaults)
} }
private class func setDefaultTheme(_ userDefaults: UserDefaults) { private class func setDefaultTheme(_ userDefaults: UserDefaults) {

Loading…
Cancel
Save