Fixes for empty channel names and empty locale, potential crash on range test config view

This commit is contained in:
Garth Vander Houwen 2022-12-09 07:19:42 -08:00
parent af1c252637
commit e2641143ca
3 changed files with 11 additions and 3 deletions

View file

@ -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) {

View file

@ -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)

View file

@ -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)