             currentPreferences[user.id] = userPrefs
         }
         let prefsData = NSKeyedArchiver.archivedData(withRootObject: currentPreferences)
-        UserDefaults.standard.set(prefsData, forKey: "user-prefs")
+        UserDefaults.standard.set(prefsData, forKey: UserPreferences.key)
     }
 }

            currentPreferences[user.id] = [seriesId: preference]
        }
        let prefsData = NSKeyedArchiver.archivedData(withRootObject: currentPreferences)
        UserDefaults.standard.set(prefsData, forKey: "user-prefs")
    }

    static func removePreference(for user: User, and seriesId: String) {


class UserPreferences {

    static let key: String = "user-prefs"

    // userId: [seriesId: prefs] -> may have more than one user due to logging out ability
    static var userPreferences: [String: [String: SeriesPreferences]] {
        get {
            if let savedData = UserDefaults.standard.value(forKey: UserPreferences.key) as? Data, let savedPrefs = NSKeyedUnarchiver.unarchiveObject(with: savedData) {
                return (savedPrefs as? [String: [String: SeriesPreferences]]) ?? [:]
            } else { // nothing saved yet
                let prefs: [String: [String: SeriesPreferences]] = [:]
                let prefsData = NSKeyedArchiver.archivedData(withRootObject: prefs)
                UserDefaults.standard.set(prefsData, forKey: UserPreferences.key)
                return prefs
            }
        }
