Clean up user defaults

This commit is contained in:
Garth Vander Houwen 2023-05-06 16:50:41 -07:00
parent e1bf4b0212
commit fa08cf8959
3 changed files with 5 additions and 37 deletions

View file

@ -10,12 +10,10 @@ import Foundation
extension UserDefaults {
enum Keys: String, CaseIterable {
case hasBeenLaunched
case meshtasticUsername
case preferredPeripheralId
case provideLocation
case provideLocationInterval
//case meshMapType
case meshMapRecentering
case meshMapShowNodeHistory
case meshMapShowRouteLines
@ -27,16 +25,6 @@ extension UserDefaults {
Keys.allCases.forEach { removeObject(forKey: $0.rawValue) }
}
static var hasBeenLaunched: Bool {
get {
let result = UserDefaults.standard.bool(forKey: "hasBeenLaunched")
UserDefaults.standard.set(true, forKey: "hasBeenLaunched")
return result
} set {
UserDefaults.standard.set(newValue, forKey: "hasBeenLaunched")
}
}
static var meshtasticUsername: String {
get {
UserDefaults.standard.string(forKey: "meshtasticUsername") ?? ""
@ -57,9 +45,7 @@ extension UserDefaults {
static var provideLocation: Bool {
get {
let result = UserDefaults.standard.bool(forKey: "provideLocation")
UserDefaults.standard.set(true, forKey: "provideLocation")
return result
UserDefaults.standard.bool(forKey: "provideLocation")
} set {
UserDefaults.standard.set(newValue, forKey: "provideLocation")
}
@ -74,15 +60,6 @@ extension UserDefaults {
}
}
// static var mapType: Int {
// get {
// UserDefaults.standard.integer(forKey: "meshMapType")
// }
// set {
// UserDefaults.standard.set(newValue, forKey: "meshMapType")
// }
// }
static var mapLayer: MapLayer {
get {
MapLayer(rawValue: UserDefaults.standard.string(forKey: "mapLayer") ?? MapLayer.standard.rawValue) ?? MapLayer.standard