Try and clear user default values on clear app settings

This commit is contained in:
Garth Vander Houwen 2023-04-04 20:14:54 -07:00
parent f1e93733ff
commit d2b0abee86
3 changed files with 25 additions and 1 deletions

View file

@ -165,3 +165,25 @@ extension String {
}
}
}
extension UserDefaults {
enum Keys: String, CaseIterable {
case meshtasticUsername
case preferredPeripheralId
case provideLocation
case provideLocationInterval
case keyboardType
case meshMapType
case meshMapCenteringMode
case meshMapRecentering
case meshMapCustomTileServer
case meshMapUserTrackingMode
case meshMapShowNodeHistory
case meshMapShowRouteLines
}
func reset() {
Keys.allCases.forEach { removeObject(forKey: $0.rawValue) }
}
}

View file

@ -36,7 +36,7 @@ struct DeviceMetricsLog: View {
x: .value("Hour", $0.time!.formattedDate(format: "ha")),
y: .value("Value", $0.batteryLevel)
)
.interpolationMethod(.cardinal)
.interpolationMethod(.linear)
.foregroundStyle(.blue)
PointMark(
x: .value("Hour", $0.time!.formattedDate(format: "ha")),

View file

@ -117,6 +117,8 @@ struct AppSettings: View {
Button("Erase all app data?", role: .destructive) {
bleManager.disconnectPeripheral()
clearCoreDataDatabase(context: context)
UserDefaults.standard.reset()
UserDefaults.standard.synchronize()
}
}
}