From f7f09c670520e4bb704a076fc2c3e2a6f9258610 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Fri, 10 Feb 2023 20:50:25 -0800 Subject: [PATCH] Sort positions the same way on both maps so we can get latest --- Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift | 2 +- Meshtastic/Views/Nodes/NodeMap.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index 44eca9a3..70e8a9e0 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -125,7 +125,7 @@ struct MapViewSwiftUI: UIViewRepresentable { annotationView.canShowCallout = true annotationView.glyphText = "📟" - let latest = parent.positions.first(where: { $0.nodePosition?.num ?? 0 == positionAnnotation.nodePosition?.num ?? -1 }) + let latest = parent.positions.last(where: { $0.nodePosition?.num ?? 0 == positionAnnotation.nodePosition?.num ?? -1 }) if latest == positionAnnotation { annotationView.markerTintColor = .systemRed diff --git a/Meshtastic/Views/Nodes/NodeMap.swift b/Meshtastic/Views/Nodes/NodeMap.swift index bfb451fc..b13caa0c 100644 --- a/Meshtastic/Views/Nodes/NodeMap.swift +++ b/Meshtastic/Views/Nodes/NodeMap.swift @@ -30,7 +30,7 @@ struct NodeMap: View { } } //&& nodePosition != nil - @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "time", ascending: false)], + @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "time", ascending: true)], predicate: NSPredicate(format: "time >= %@ && nodePosition != nil", Calendar.current.startOfDay(for: Date()) as NSDate), animation: .none) private var positions: FetchedResults