mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Protect against weird channel index problems
This commit is contained in:
parent
3ee7777c06
commit
8c19fa0fc4
2 changed files with 16 additions and 2 deletions
|
|
@ -46,7 +46,7 @@ struct AboutMeshtastic: View {
|
|||
Link("Documentation", destination: URL(string: "https://meshtastic.org/docs/getting-started")!)
|
||||
.font(.title2)
|
||||
}
|
||||
Text("Meshtastic Copyright(c) Meshtastic LLC")
|
||||
Text("Meshtastic® Copyright Meshtastic LLC")
|
||||
.font(.caption)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ struct Channels: View {
|
|||
Button {
|
||||
let key = generateChannelKey(size: 32)
|
||||
channelName = ""
|
||||
channelIndex = Int32(node!.myInfo!.channels!.array.count)
|
||||
channelIndex = Int32((node!.myInfo!.channels!.array.count) - 1)
|
||||
channelRole = 2
|
||||
channelKey = key
|
||||
uplink = false
|
||||
|
|
@ -247,6 +247,20 @@ struct Channels: View {
|
|||
channel.settings.psk = Data(base64Encoded: channelKey) ?? Data()
|
||||
channel.settings.uplinkEnabled = uplink
|
||||
channel.settings.downlinkEnabled = downlink
|
||||
|
||||
} else {
|
||||
if channelIndex <= node!.myInfo!.channels?.count ?? 0 {
|
||||
let channelEntity = node!.myInfo!.channels?[Int(channelIndex)] as! ChannelEntity
|
||||
context.delete(channelEntity)
|
||||
do {
|
||||
try context.save()
|
||||
print("💾 Deleted Channel: \(channel.settings.name)")
|
||||
} catch {
|
||||
context.rollback()
|
||||
let nsError = error as NSError
|
||||
print("💥 Unresolved Core Data error in the channel editor. Error: \(nsError)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let adminMessageId = bleManager.saveChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue