diff --git a/Meshtastic/Helpers/WatchSessionManager.swift b/Meshtastic/Helpers/WatchSessionManager.swift index 872eb074..93b53681 100644 --- a/Meshtastic/Helpers/WatchSessionManager.swift +++ b/Meshtastic/Helpers/WatchSessionManager.swift @@ -37,6 +37,12 @@ final class WatchSessionManager: NSObject, ObservableObject { // MARK: - Public API + /// Whether a paired Watch with the Meshtastic app installed is available. + var isWatchAvailable: Bool { + guard let session, session.activationState == .activated else { return false } + return session.isPaired && session.isWatchAppInstalled + } + /// Send a specific node to the Watch as a foxhunt target. /// The Watch will pin this node in its foxhunt list regardless of distance. func sendNodeForFoxhunt(_ nodeNum: Int64) { diff --git a/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift b/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift index f282881f..2d7e57be 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift @@ -8,7 +8,6 @@ import WeatherKit import MapKit import CoreLocation import OSLog -import WatchConnectivity struct NodeDetail: View { private let gridItemLayout = Array(repeating: GridItem(.flexible(), spacing: 10), count: 2) @@ -480,7 +479,7 @@ struct NodeDetail: View { } if node.hasPositions { #if !targetEnvironment(macCatalyst) - if node.latestPosition?.isPreciseLocation == true && WCSession.isSupported() && WCSession.default.isPaired && WCSession.default.isWatchAppInstalled { + if node.latestPosition?.isPreciseLocation == true && WatchSessionManager.shared.isWatchAvailable { Button { WatchSessionManager.shared.sendNodeForFoxhunt(node.num) } label: {