From e2641143cab14526f67834a677b96115ceb5e2af Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Fri, 9 Dec 2022 07:19:42 -0800 Subject: [PATCH] Fixes for empty channel names and empty locale, potential crash on range test config view --- Meshtastic/Views/Messages/Contacts.swift | 10 +++++++++- Meshtastic/Views/Settings/About.swift | 2 +- .../Views/Settings/Config/Module/RangeTestConfig.swift | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Meshtastic/Views/Messages/Contacts.swift b/Meshtastic/Views/Messages/Contacts.swift index d22b019e..54b00d9e 100644 --- a/Meshtastic/Views/Messages/Contacts.swift +++ b/Meshtastic/Views/Messages/Contacts.swift @@ -46,7 +46,15 @@ struct Contacts: View { .padding(.trailing, 5) VStack { HStack { - Text(String(channel.name ?? "Channel \(channel.index)").camelCaseToWords()).font(.headline) + if channel.name?.isEmpty ?? false { + if channel.role == 1 { + Text(String("PrimaryChannel").camelCaseToWords()).font(.headline) + } else { + Text(String("Channel \(channel.index)").camelCaseToWords()).font(.headline) + } + } else { + Text(String(channel.name ?? "Channel \(channel.index)").camelCaseToWords()).font(.headline) + } Spacer() if channel.allPrivateMessages.count > 0 { VStack (alignment: .trailing) { diff --git a/Meshtastic/Views/Settings/About.swift b/Meshtastic/Views/Settings/About.swift index d880b3fe..8cc59d3c 100644 --- a/Meshtastic/Views/Settings/About.swift +++ b/Meshtastic/Views/Settings/About.swift @@ -34,7 +34,7 @@ struct AboutMeshtastic: View { Link("GitHub Repository", destination: URL(string: "https://github.com/meshtastic/Meshtastic-Apple")!) .font(.title2) } - if locale.region?.identifier == "US" { + if locale.region?.identifier ?? "no locale" == "US" { Section(header: Text("Get Devices")) { Link("Buy Complete Radios", destination: URL(string: "https://www.etsy.com/shop/GarthVH")!) .font(.title2) diff --git a/Meshtastic/Views/Settings/Config/Module/RangeTestConfig.swift b/Meshtastic/Views/Settings/Config/Module/RangeTestConfig.swift index 58c51e6d..f65a61b2 100644 --- a/Meshtastic/Views/Settings/Config/Module/RangeTestConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/RangeTestConfig.swift @@ -89,7 +89,7 @@ struct RangeTestConfig: View { } label: { Label("Save", systemImage: "square.and.arrow.down") } - .disabled(bleManager.connectedPeripheral == nil || !hasChanges || !(node!.myInfo?.hasWifi ?? false)) + .disabled(bleManager.connectedPeripheral == nil || !hasChanges || !(node?.myInfo?.hasWifi ?? false)) .buttonStyle(.bordered) .buttonBorderShape(.capsule) .controlSize(.large)