From 537fd2d386ee74d17c1839cf4aa4d8be260554e8 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 15 Jul 2025 15:49:46 -0700 Subject: [PATCH 1/2] Node navigation cleanup --- Meshtastic/MeshtasticAppDelegate.swift | 21 +++------------------ Meshtastic/Views/Nodes/NodeList.swift | 8 +++++--- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/Meshtastic/MeshtasticAppDelegate.swift b/Meshtastic/MeshtasticAppDelegate.swift index f4c405bb..0c7ada6e 100644 --- a/Meshtastic/MeshtasticAppDelegate.swift +++ b/Meshtastic/MeshtasticAppDelegate.swift @@ -50,7 +50,7 @@ class MeshtasticAppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificat case "messageNotification.thumbsUpAction": if let channel = userInfo["channel"] as? Int32, let replyID = userInfo["messageId"] as? Int64 { - let tapbackResponse = !BLEManager.shared.sendMessage( + let tapbackResponse = !BLEManager.shared.sendMessage ( message: Tapbacks.thumbsUp.emojiString, toUserNum: userInfo["userNum"] as? Int64 ?? 0, channel: channel, @@ -64,7 +64,7 @@ class MeshtasticAppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificat case "messageNotification.thumbsDownAction": if let channel = userInfo["channel"] as? Int32, let replyID = userInfo["messageId"] as? Int64 { - let tapbackResponse = !BLEManager.shared.sendMessage( + let tapbackResponse = !BLEManager.shared.sendMessage ( message: Tapbacks.thumbsDown.emojiString, toUserNum: userInfo["userNum"] as? Int64 ?? 0, channel: channel, @@ -79,7 +79,7 @@ class MeshtasticAppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificat if let userInput = (response as? UNTextInputNotificationResponse)?.userText, let channel = userInfo["channel"] as? Int32, let replyID = userInfo["messageId"] as? Int64 { - let tapbackResponse = !BLEManager.shared.sendMessage( + let tapbackResponse = !BLEManager.shared.sendMessage ( message: userInput, toUserNum: userInfo["userNum"] as? Int64 ?? 0, channel: channel, @@ -98,21 +98,6 @@ class MeshtasticAppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificat let deepLink = userInfo["path"] as? String, let url = URL(string: deepLink) { Logger.services.info("userNotificationCenter didReceiveResponse handling deeplink: \(targetValue, privacy: .public) \(deepLink, privacy: .public)") - // Handle TraceRoute notifications specially to ensure they navigate correctly - if deepLink.contains("meshtastic:///nodes") && deepLink.contains("nodenum=") { - // First extract the node number from the URL - if let nodeNumString = deepLink.components(separatedBy: "nodenum=").last, - let nodeNum = Int64(nodeNumString) { - Logger.services.info("Navigation to specific node via notification: \(nodeNum, privacy: .public)") - self.router?.navigationState.selectedTab = .nodes - // Post a notification to trigger app-wide refresh - NotificationCenter.default.post(name: NSNotification.Name("ForceNavigationRefresh"), - object: nil, - userInfo: ["nodeNum": nodeNum]) - self.router?.navigationState.nodeListSelectedNodeNum = nodeNum - } - } - // Still call the regular router in all cases router?.route(url: url) } else { Logger.services.error("Failed to handle notification response: \(userInfo, privacy: .public)") diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 82522223..3555f1b8 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -284,9 +284,6 @@ struct NodeList: View { // Make sure the ZStack passes through accessibility to the ConnectedDevice component .accessibilityElement(children: .contain) ) - .onDisappear { - router.navigationState.nodeListSelectedNodeNum = nil - } } } else { ContentUnavailableView("Select Node", systemImage: "flipphone") @@ -341,6 +338,11 @@ struct NodeList: View { await searchNodeList() } } + .onChange(of: selectedNode) { + if selectedNode === nil { + router.navigationState.nodeListSelectedNodeNum = nil + } + } .onChange(of: router.navigationState) { if let selected = router.navigationState.nodeListSelectedNodeNum { // Force a complete view rebuild by generating a new UUID From f2137a92c5109e9b12ff2fb65fe0c4c661909a22 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 15 Jul 2025 15:51:33 -0700 Subject: [PATCH 2/2] Update Meshtastic/Views/Nodes/NodeList.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Meshtastic/Views/Nodes/NodeList.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 3555f1b8..fcb2a5ef 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -339,7 +339,7 @@ struct NodeList: View { } } .onChange(of: selectedNode) { - if selectedNode === nil { + if selectedNode == nil { router.navigationState.nodeListSelectedNodeNum = nil } }