From 4c25e8a5892efc2da57bcd84617c20b12d2a7f70 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Wed, 5 Apr 2023 21:26:53 -0700 Subject: [PATCH] Fix environment metrics log --- Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift | 3 ++- Meshtastic/Views/Nodes/DeviceMetricsLog.swift | 2 +- Meshtastic/Views/Nodes/EnvironmentMetricsLog.swift | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index 6bfc4cd7..184bab52 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -121,9 +121,10 @@ struct MapViewSwiftUI: UIViewRepresentable { .filter { $0.latest == true } .sorted { $0.nodePosition?.num ?? 0 > $1.nodePosition?.num ?? -1 } let annotationCount = waypoints.count + (showNodeHistory ? positions.count : latest.count) - print("Annotation Count: \(annotationCount) Map Annotations: \(mapView.annotations.count)") + if annotationCount != mapView.annotations.count { + print("Annotation Count: \(annotationCount) Map Annotations: \(mapView.annotations.count)") mapView.removeAnnotations(mapView.annotations) mapView.addAnnotations(waypoints) if showRouteLines { diff --git a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift index 8451da12..7c9da7a2 100644 --- a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift +++ b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift @@ -190,7 +190,7 @@ struct DeviceMetricsLog: View { } } Button { - exportString = telemetryToCsvFile(telemetry: node.telemetries!.array as? [TelemetryEntity] ?? [], metricsType: 0) + exportString = telemetryToCsvFile(telemetry: deviceMetrics, metricsType: 0) isExporting = true } label: { Label("save", systemImage: "square.and.arrow.down") diff --git a/Meshtastic/Views/Nodes/EnvironmentMetricsLog.swift b/Meshtastic/Views/Nodes/EnvironmentMetricsLog.swift index e9655414..e20eac29 100644 --- a/Meshtastic/Views/Nodes/EnvironmentMetricsLog.swift +++ b/Meshtastic/Views/Nodes/EnvironmentMetricsLog.swift @@ -79,7 +79,7 @@ struct EnvironmentMetricsLog: View { .font(.caption) .fontWeight(.bold) } - ForEach(node.telemetries?.reversed() as? [TelemetryEntity] ?? [], id: \.self) { (em: TelemetryEntity) in + ForEach(environmentMetrics, id: \.self) { em in GridRow { @@ -124,7 +124,7 @@ struct EnvironmentMetricsLog: View { } } Button { - exportString = telemetryToCsvFile(telemetry: node.telemetries!.array as? [TelemetryEntity] ?? [], metricsType: 1) + exportString = telemetryToCsvFile(telemetry: environmentMetrics, metricsType: 1) isExporting = true } label: { Label("save", systemImage: "square.and.arrow.down")