mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix crashes
This commit is contained in:
parent
0dcdd4f009
commit
0c915863d5
5 changed files with 11 additions and 9 deletions
|
|
@ -38,7 +38,11 @@ extension String {
|
|||
return false
|
||||
} else {
|
||||
let characters = Array(self)
|
||||
return characters[0].isEmoji
|
||||
if characters.count <= 0 {
|
||||
return false
|
||||
} else {
|
||||
return characters[0].isEmoji
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
positionPacket.timestamp = UInt32(LocationHelper.currentTimestamp.timeIntervalSince1970)
|
||||
positionPacket.altitude = Int32(LocationHelper.currentAltitude)
|
||||
positionPacket.satsInView = UInt32(LocationHelper.satsInView)
|
||||
if LocationHelper.currentSpeed >= 0 {
|
||||
if !LocationHelper.currentSpeed.isNaN || !LocationHelper.currentSpeed.isInfinite {
|
||||
positionPacket.groundSpeed = UInt32(LocationHelper.currentSpeed * 3.6)
|
||||
}
|
||||
if (!LocationHelper.currentHeading.isNaN || !LocationHelper.currentHeading.isInfinite) {
|
||||
|
|
|
|||
|
|
@ -143,10 +143,9 @@ struct NodeMap: View {
|
|||
Text("Enable Offline Maps")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
.onTapGesture {
|
||||
self.enableOfflineMaps.toggle()
|
||||
UserDefaults.enableOfflineMaps = self.enableOfflineMaps
|
||||
if !self.enableOfflineMaps {
|
||||
.onChange(of: (enableOfflineMaps)) { newEnableOfflineMaps in
|
||||
UserDefaults.enableOfflineMaps = newEnableOfflineMaps
|
||||
if !newEnableOfflineMaps {
|
||||
if self.selectedMapLayer == .offline {
|
||||
self.selectedMapLayer = .standard
|
||||
}
|
||||
|
|
@ -166,7 +165,6 @@ struct NodeMap: View {
|
|||
.pickerStyle(DefaultPickerStyle())
|
||||
.onChange(of: (selectedTileServer)) { newSelectedTileServer in
|
||||
UserDefaults.mapTileServer = newSelectedTileServer
|
||||
selectedMapLayer = .standard
|
||||
}
|
||||
Text("Attribution:")
|
||||
.fontWeight(.semibold)
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ struct DeviceConfig: View {
|
|||
if bleManager.connectedPeripheral != nil && node?.deviceConfig == nil {
|
||||
print("empty device config")
|
||||
let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral?.num ?? -1, context: context)
|
||||
if node != nil && connectedNode != nil {
|
||||
if node != nil && connectedNode != nil && connectedNode?.user != nil {
|
||||
_ = bleManager.requestDeviceConfig(fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ struct Settings: View {
|
|||
let connectedNode = nodes.first(where: { $0.num == connectedNodeNum })
|
||||
connectedNodeNum = Int(bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral?.num ?? 0 : 0)
|
||||
|
||||
if node?.metadata == nil {
|
||||
if connectedNode != nil && node?.metadata == nil {
|
||||
let adminMessageId = bleManager.requestDeviceMetadata(fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode!.myInfo!.adminIndex, context: context)
|
||||
|
||||
if adminMessageId > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue