From 2214e01666cdc61ea8cd5f8691f38ad5785062b6 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 7 Oct 2021 07:37:33 -0700 Subject: [PATCH] Use title and content for notifications, remove extra ) --- MeshtasticClient/Helpers/BLEManager.swift | 21 +++++++++++-------- .../Helpers/LocalNotificationManager.swift | 2 ++ MeshtasticClient/Views/Nodes/NodeMap.swift | 2 +- MeshtasticClient/Views/Nodes/NodeRow.swift | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/MeshtasticClient/Helpers/BLEManager.swift b/MeshtasticClient/Helpers/BLEManager.swift index 4aea97b4..04df7766 100644 --- a/MeshtasticClient/Helpers/BLEManager.swift +++ b/MeshtasticClient/Helpers/BLEManager.swift @@ -315,9 +315,8 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph if decodedInfo.myInfo.myNodeNum != 0 { - print("Save a myInfo") + print("Save myInfo for \(decodedInfo.myInfo.myNodeNum)") do { - // print(try decodedInfo.myInfo.jsonString()) // Create a MyInfoModel let myInfoModel = MyInfoModel( @@ -425,7 +424,11 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph let manager = LocalNotificationManager() manager.notifications = [ - Notification(id: ("notifiction.id.\(decodedInfo.packet.id)"), title: ("\(fromUser?.user.shortName ?? "???") says \(messageText))"))] + Notification( + id: ("notification.id.\(decodedInfo.packet.id)"), + title: "\(fromUser?.user.longName ?? "???") AKA \(fromUser?.user.shortName ?? "") says ", + content: messageText) + ] manager.schedule() manager.listScheduledNotifications() @@ -436,15 +439,15 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph } else if decodedInfo.packet.decoded.portnum == PortNum.nodeinfoApp { - var updatedNode = meshData.nodes.first(where: {$0.id == decodedInfo.packet.from}) + var updatedNode = meshData.nodes.first(where: {$0.id == decodedInfo.packet.from }) updatedNode!.snr = decodedInfo.packet.rxSnr updatedNode!.lastHeard = decodedInfo.packet.rxTime - // updatedNode!.user.longName = "Node Info updated longname" - // updatedNode!.update(from: updatedNode!.data) + // updatedNode!.user.longName = "Node Info updated longname" + updatedNode!.update(from: updatedNode!.data) - let nodeIndex = meshData.nodes.firstIndex(where: { $0.id == decodedInfo.packet.from }) - meshData.nodes.remove(at: nodeIndex!) - meshData.nodes.append(updatedNode!) + //let nodeIndex = meshData.nodes.firstIndex(where: { $0.id == decodedInfo.packet.from }) + //meshData.nodes.remove(at: nodeIndex!) + //meshData.nodes.append(updatedNode!) meshData.save() print("Updated NodeInfo SNR and Time from Packet For: \(updatedNode!.user.longName)") } diff --git a/MeshtasticClient/Helpers/LocalNotificationManager.swift b/MeshtasticClient/Helpers/LocalNotificationManager.swift index 54f795b5..f3e8b668 100644 --- a/MeshtasticClient/Helpers/LocalNotificationManager.swift +++ b/MeshtasticClient/Helpers/LocalNotificationManager.swift @@ -39,6 +39,7 @@ class LocalNotificationManager { { let content = UNMutableNotificationContent() content.title = notification.title + content.body = notification.content content.sound = .default let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false) @@ -70,4 +71,5 @@ class LocalNotificationManager { struct Notification { var id: String var title: String + var content: String } diff --git a/MeshtasticClient/Views/Nodes/NodeMap.swift b/MeshtasticClient/Views/Nodes/NodeMap.swift index 0f5cf6f5..194e5465 100644 --- a/MeshtasticClient/Views/Nodes/NodeMap.swift +++ b/MeshtasticClient/Views/Nodes/NodeMap.swift @@ -30,7 +30,7 @@ struct NodeMap: View { var body: some View { let location = LocationHelper.currentLocation - let currentCoordinatePosition = CLLocationCoordinate2D(latitude: location.latitude, longitude: location.longitude) + let currentCoordinatePosition = CLLocationCoordinate2D(latitude: locationNodes[0].position.latitude ?? location.latitude, longitude: locationNodes[0].position.latitude ?? location.longitude) let regionBinding = Binding( get: { MKCoordinateRegion(center: currentCoordinatePosition, span: MKCoordinateSpan(latitudeDelta: 0.0359, longitudeDelta: 0.0359)) diff --git a/MeshtasticClient/Views/Nodes/NodeRow.swift b/MeshtasticClient/Views/Nodes/NodeRow.swift index 7b0bb978..1a649474 100644 --- a/MeshtasticClient/Views/Nodes/NodeRow.swift +++ b/MeshtasticClient/Views/Nodes/NodeRow.swift @@ -16,7 +16,7 @@ struct NodeRow: View { HStack (alignment: .bottom){ - Image(systemName: "timer").font(.headline).foregroundColor(.blue).symbolRenderingMode(.hierarchical) + Image(systemName: "timer.square").font(.headline).foregroundColor(.blue).symbolRenderingMode(.hierarchical) if connected { Text("Currently Connected").font(.subheadline).foregroundColor(Color.accentColor)