diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index acd68368..b2f1e9b4 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -759,7 +759,8 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { wayPointEntity.icon = Int64(waypoint.icon) wayPointEntity.latitudeI = waypoint.latitudeI wayPointEntity.longitudeI = waypoint.longitudeI - if waypoint.expire > 0 { + + if waypoint.expire > 1 { wayPointEntity.expire = Date.init(timeIntervalSince1970: Double(waypoint.expire)) } else { wayPointEntity.expire = nil @@ -769,6 +770,11 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { } else { wayPointEntity.locked = 0 } + if wayPointEntity.created == nil { + wayPointEntity.created = Date() + } else { + wayPointEntity.lastUpdated = Date() + } do { try context!.save() print("💾 Updated Waypoint from Waypoint App Packet From: \(fromNodeNum)") diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index a7d08c04..1f66aa57 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -806,9 +806,10 @@ func waypointPacket (packet: MeshPacket, context: NSManagedObjectContext) { waypoint.locked = Int64(waypointMessage.lockedTo) if waypointMessage.expire > 0 { waypoint.expire = Date(timeIntervalSince1970: TimeInterval(Int64(waypointMessage.expire))) + }else { + waypoint.expire = nil } waypoint.created = Date() - waypoint.lastUpdated = Date() do { try context.save() print("💾 Updated Node Waypoint App Packet For: \(waypoint.id)") @@ -825,8 +826,10 @@ func waypointPacket (packet: MeshPacket, context: NSManagedObjectContext) { fetchedWaypoint[0].longitudeI = waypointMessage.longitudeI fetchedWaypoint[0].icon = Int64(waypointMessage.icon) fetchedWaypoint[0].locked = Int64(waypointMessage.lockedTo) - if waypointMessage.expire > 0 { + if waypointMessage.expire > 1 { fetchedWaypoint[0].expire = Date(timeIntervalSince1970: TimeInterval(Int64(waypointMessage.expire))) + } else { + fetchedWaypoint[0].expire = nil } fetchedWaypoint[0].lastUpdated = Date() do { diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index 3da58087..bb923386 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -174,7 +174,21 @@ struct MapViewSwiftUI: UIViewRepresentable { leftIcon.backgroundColor = UIColor(.accentColor) annotationView.leftCalloutAccessoryView = leftIcon let subtitle = UILabel() - subtitle.text = waypointAnnotation.longDescription + if subtitle.text?.count ?? 0 > 0 { + subtitle.text = (waypointAnnotation.longDescription ?? "") + "\n" + } + else { + subtitle.text = "" + } + if waypointAnnotation.created != nil { + subtitle.text! += "Created: \(waypointAnnotation.created?.formatted() ?? "Unknown") \n" + } + if waypointAnnotation.lastUpdated != nil { + subtitle.text! += "Updated: \(waypointAnnotation.lastUpdated?.formatted() ?? "Unknown") \n" + } + if waypointAnnotation.expire != nil { + subtitle.text! += "Expires: \(waypointAnnotation.expire?.formatted() ?? "Unknown") \n" + } subtitle.numberOfLines = 0 annotationView.detailCalloutAccessoryView = subtitle let editIcon = UIButton(type: .detailDisclosure) diff --git a/Meshtastic/Views/Map/WaypointFormView.swift b/Meshtastic/Views/Map/WaypointFormView.swift index fcaf8766..5357c930 100644 --- a/Meshtastic/Views/Map/WaypointFormView.swift +++ b/Meshtastic/Views/Map/WaypointFormView.swift @@ -151,8 +151,10 @@ struct WaypointFormView: View { newWaypoint.lockedTo = UInt32(lockedTo) } } - if expire.timeIntervalSince1970 > 0 { + if expires { newWaypoint.expire = UInt32(expire.timeIntervalSince1970) + } else { + newWaypoint.expire = 0 } if bleManager.sendWaypoint(waypoint: newWaypoint) { waypointId = 0 @@ -198,9 +200,7 @@ struct WaypointFormView: View { if waypointId > 0 { newWaypoint.id = UInt32(waypointId) - } else { - newWaypoint.id = UInt32.random(in: UInt32(UInt8.max).. 0 ? name : "Dropped Pin" newWaypoint.description_p = description newWaypoint.latitudeI = Int32(coordinate.latitude * 1e7)