From d2b0abee86c6f0dcaf28be7f2cf3f0b4b41fac32 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 4 Apr 2023 20:14:54 -0700 Subject: [PATCH] Try and clear user default values on clear app settings --- Meshtastic/Helpers/Extensions.swift | 22 +++++++++++++++++++ Meshtastic/Views/Nodes/DeviceMetricsLog.swift | 2 +- Meshtastic/Views/Settings/AppSettings.swift | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Helpers/Extensions.swift b/Meshtastic/Helpers/Extensions.swift index 51a02608..f4b6a0ae 100644 --- a/Meshtastic/Helpers/Extensions.swift +++ b/Meshtastic/Helpers/Extensions.swift @@ -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) } + } +} diff --git a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift index a99d98a4..13c41f31 100644 --- a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift +++ b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift @@ -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")), diff --git a/Meshtastic/Views/Settings/AppSettings.swift b/Meshtastic/Views/Settings/AppSettings.swift index ec83fae9..dae61991 100644 --- a/Meshtastic/Views/Settings/AppSettings.swift +++ b/Meshtastic/Views/Settings/AppSettings.swift @@ -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() } } }