From f6032a8439e2dba9dd7c1085f6d93b3b3caab61d Mon Sep 17 00:00:00 2001 From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com> Date: Wed, 20 Apr 2022 09:33:13 -0400 Subject: [PATCH] Inject Data Store + Defaults in AppDefaults.swift --- Clocker/Overall App/AppDefaults.swift | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Clocker/Overall App/AppDefaults.swift b/Clocker/Overall App/AppDefaults.swift index 33dc0b0..7224c48 100644 --- a/Clocker/Overall App/AppDefaults.swift +++ b/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) {