mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix some linting and ben writing C# warnings
This commit is contained in:
parent
73f1f65553
commit
70340fa18f
13 changed files with 12 additions and 29 deletions
|
|
@ -13,7 +13,6 @@ struct DisconnectNodeIntent: AppIntent {
|
|||
|
||||
static var description: IntentDescription = "Disconnect the currently connected node"
|
||||
|
||||
|
||||
func perform() async throws -> some IntentResult {
|
||||
if !BLEManager.shared.isConnected {
|
||||
throw AppIntentErrors.AppIntentError.notConnected
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ struct ShortcutsProvider: AppShortcutsProvider {
|
|||
"Send a \(.applicationName) group message"],
|
||||
shortTitle: "Group Message",
|
||||
systemImageName: "message")
|
||||
|
||||
AppShortcut(intent: DisconnectNodeIntent(),
|
||||
phrases: ["Disconnect \(.applicationName) node",
|
||||
"Disconnect my \(.applicationName) node",
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ extension UserDefaults {
|
|||
|
||||
@UserDefault(.enableMapPointsOfInterest, defaultValue: false)
|
||||
static var enableMapPointsOfInterest: Bool
|
||||
|
||||
|
||||
@UserDefault(.enableMapShowFavorites, defaultValue: false)
|
||||
static var enableMapShowFavorites: Bool
|
||||
|
||||
|
|
|
|||
|
|
@ -181,11 +181,9 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self = self else { return }
|
||||
guard let connectedPeripheral = self.connectedPeripheral else { return }
|
||||
|
||||
if self.mqttProxyConnected {
|
||||
self.mqttManager.mqttClientProxy?.disconnect()
|
||||
}
|
||||
|
||||
self.automaticallyReconnect = reconnect
|
||||
self.centralManager?.cancelPeripheralConnection(connectedPeripheral.peripheral)
|
||||
self.FROMRADIO_characteristic = nil
|
||||
|
|
@ -1810,13 +1808,11 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
if let nodeInfoData = try? contact.user.serializedData() {
|
||||
dataNodeMessage.payload = nodeInfoData
|
||||
dataNodeMessage.portnum = PortNum.nodeinfoApp
|
||||
|
||||
var nodeMeshPacket = MeshPacket()
|
||||
nodeMeshPacket.id = UInt32.random(in: UInt32(UInt8.max)..<UInt32.max)
|
||||
nodeMeshPacket.to = UInt32.max
|
||||
nodeMeshPacket.from = UInt32(contact.nodeNum)
|
||||
nodeMeshPacket.decoded = dataNodeMessage
|
||||
|
||||
// Update local database with the new node info
|
||||
upsertNodeInfoPacket(packet: nodeMeshPacket, context: context)
|
||||
}
|
||||
|
|
@ -1841,7 +1837,6 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
return false
|
||||
}
|
||||
|
||||
|
||||
public func saveUser(config: User, fromUser: UserEntity, toUser: UserEntity, adminIndex: Int32) -> Int64 {
|
||||
var adminPacket = AdminMessage()
|
||||
adminPacket.setOwner = config
|
||||
|
|
|
|||
|
|
@ -142,7 +142,6 @@ import CoreData
|
|||
Logger.services.info("📍 [App] Falling back to last known location (age: \(Int(Date().timeIntervalSince1970 - timestamp)) seconds)")
|
||||
return CLLocationCoordinate2D(latitude: lat, longitude: lon)
|
||||
}
|
||||
|
||||
// Fallback 2: Default location
|
||||
Logger.services.warning("📍 [App] No Location and no last known location, something is really wrong. Teleporting user to Apple Park")
|
||||
return DefaultLocation
|
||||
|
|
|
|||
|
|
@ -1058,7 +1058,6 @@ func textMessageAppPacket(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func waypointPacket (packet: MeshPacket, context: NSManagedObjectContext) {
|
||||
|
||||
let logString = String.localizedStringWithFormat("Waypoint Packet received from node: %@".localized, String(packet.from))
|
||||
|
|
|
|||
|
|
@ -61,10 +61,9 @@ struct MeshtasticAppleApp: App {
|
|||
Logger.mesh.debug("URL received \(userActivity, privacy: .public)")
|
||||
self.incomingUrl = userActivity.webpageURL
|
||||
self.saveChannels = false
|
||||
if (self.incomingUrl?.absoluteString.lowercased().contains("meshtastic.org/v/#") == true) {
|
||||
if self.incomingUrl?.absoluteString.lowercased().contains("meshtastic.org/v/#") == true {
|
||||
handleContactUrl(url: self.incomingUrl!)
|
||||
}
|
||||
else if (self.incomingUrl?.absoluteString.lowercased().contains("meshtastic.org/e/#") == true) {
|
||||
} else if self.incomingUrl?.absoluteString.lowercased().contains("meshtastic.org/e/#") == true {
|
||||
if let components = self.incomingUrl?.absoluteString.components(separatedBy: "#") {
|
||||
self.addChannels = Bool(self.incomingUrl?["add"] ?? "false") ?? false
|
||||
if (self.incomingUrl?.absoluteString.lowercased().contains("?")) != nil {
|
||||
|
|
@ -153,19 +152,19 @@ struct MeshtasticAppleApp: App {
|
|||
let components = self.incomingUrl?.absoluteString.components(separatedBy: "#") ?? []
|
||||
// Extract contact information from the URL
|
||||
if let contactData = components.last {
|
||||
|
||||
|
||||
let decodedString = contactData.base64urlToBase64()
|
||||
if let decodedData = Data(base64Encoded: decodedString) {
|
||||
do {
|
||||
let contact = try MeshtasticProtobufs.SharedContact(serializedBytes: decodedData)
|
||||
|
||||
|
||||
// Show an alert to confirm adding the contact
|
||||
let alertController = UIAlertController(
|
||||
title: "Add Contact",
|
||||
message: "Would you like to add \(contact.user.longName) as a contact?",
|
||||
preferredStyle: .alert
|
||||
)
|
||||
|
||||
|
||||
alertController.addAction(UIAlertAction(
|
||||
title: "Yes",
|
||||
style: .default,
|
||||
|
|
@ -174,13 +173,13 @@ struct MeshtasticAppleApp: App {
|
|||
Logger.services.debug("Contact added from URL: \(success ? "success" : "failed")")
|
||||
}
|
||||
))
|
||||
|
||||
|
||||
alertController.addAction(UIAlertAction(
|
||||
title: "No",
|
||||
style: .cancel,
|
||||
handler: nil
|
||||
))
|
||||
|
||||
|
||||
// Present the alert
|
||||
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
||||
let rootViewController = windowScene.windows.first?.rootViewController {
|
||||
|
|
@ -189,7 +188,7 @@ struct MeshtasticAppleApp: App {
|
|||
Logger.services.debug("Contact data extracted from URL: \(contactData, privacy: .public)")
|
||||
} catch {
|
||||
Logger.services.error("Failed to parse contact data: \(error.localizedDescription, privacy: .public)")
|
||||
|
||||
|
||||
// Show error alert to user
|
||||
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
||||
let rootViewController = windowScene.windows.first?.rootViewController {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ struct BatteryCompact: View {
|
|||
// Check for plugged in state
|
||||
let isPluggedIn = batteryLevel > 100
|
||||
let isCharging = batteryLevel == 100
|
||||
|
||||
// Battery icon selection based on level
|
||||
if isPluggedIn {
|
||||
Image(systemName: "powerplug")
|
||||
|
|
@ -64,7 +63,6 @@ struct BatteryCompact: View {
|
|||
.symbolRenderingMode(.multicolor)
|
||||
.accessibilityHidden(true)
|
||||
}
|
||||
|
||||
// Battery text label
|
||||
if isPluggedIn {
|
||||
Text("PWD")
|
||||
|
|
@ -89,7 +87,6 @@ struct BatteryCompact: View {
|
|||
.foregroundColor(color)
|
||||
.symbolRenderingMode(.multicolor)
|
||||
.accessibilityHidden(true)
|
||||
|
||||
Text(verbatim: "?")
|
||||
.foregroundStyle(.secondary)
|
||||
.font(font)
|
||||
|
|
@ -100,7 +97,7 @@ struct BatteryCompact: View {
|
|||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel(NSLocalizedString("Battery Level", comment: "VoiceOver label for battery gauge"))
|
||||
// Set appropriate value based on the battery state using a computed property
|
||||
.accessibilityValue(batteryLevel.map { level in
|
||||
.accessibilityValue(batteryLevel.map { level in
|
||||
if level > 100 {
|
||||
// Plugged in - same as PWD visual indicator
|
||||
return "Plugged in".localized
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ struct LoRaSignalStrengthMeter_Previews: PreviewProvider {
|
|||
LoRaSignalStrengthMeter(snr: -26.0, rssi: -128, preset: ModemPresets.longFast, compact: true)
|
||||
.padding(.bottom)
|
||||
}.padding()
|
||||
|
||||
HStack {
|
||||
// Good
|
||||
LoRaSignalStrengthMeter(snr: -1, rssi: -114, preset: ModemPresets.longFast, compact: false)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ struct UserMessageList: View {
|
|||
@State private var hasReachedBottom = false
|
||||
@State private var gotFirstUnreadMessage: Bool = false
|
||||
@State private var messageToHighlight: Int64 = 0
|
||||
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
ScrollViewReader { scrollView in
|
||||
|
|
@ -51,7 +51,6 @@ struct UserMessageList: View {
|
|||
messageToHighlight = messageNum
|
||||
}
|
||||
scrollView.scrollTo(messageNum, anchor: .center)
|
||||
|
||||
// Reset highlight after delay
|
||||
Task {
|
||||
try? await Task.sleep(nanoseconds: 1_000_000_000) // 1 second
|
||||
|
|
|
|||
|
|
@ -364,7 +364,6 @@ struct NodeList: View {
|
|||
Logger.services.info("NodeList directly updated from notification for node: \(nodeNum, privacy: .public)")
|
||||
}
|
||||
}
|
||||
|
||||
Task {
|
||||
await searchNodeList()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,7 +248,6 @@ struct LoRaConfig: View {
|
|||
/// 2.5 Administration with session passkey
|
||||
let expiration = node.sessionExpiration ?? Date()
|
||||
if expiration < Date() || node.loRaConfig == nil {
|
||||
|
||||
Logger.mesh.info("⚙️ Empty or expired lora config requesting via PKI admin")
|
||||
if connectedNode.user != nil && node.user != nil {
|
||||
_ = bleManager.requestLoRaConfig(fromUser: connectedNode.user!, toUser: node.user!, adminIndex: connectedNode.myInfo?.adminIndex ?? 0)
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ struct UserConfig: View {
|
|||
} else {
|
||||
var ham = HamParameters()
|
||||
ham.shortName = shortName
|
||||
//ham.isUnmessagable = isUnmessagable
|
||||
// ham.isUnmessagable = isUnmessagable
|
||||
ham.callSign = longName
|
||||
ham.txPower = Int32(txPower)
|
||||
ham.frequency = overrideFrequency
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue