Sort positions the same way on both maps so we can get latest

This commit is contained in:
Garth Vander Houwen 2023-02-10 20:50:25 -08:00
parent 243dd75456
commit f7f09c6705
2 changed files with 2 additions and 2 deletions

View file

@ -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

View file

@ -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<PositionEntity>