mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix canned messages
This commit is contained in:
parent
416960388f
commit
7da242d70f
1 changed files with 30 additions and 27 deletions
|
|
@ -207,37 +207,40 @@ struct CannedMessagesConfig: View {
|
|||
let nodeName = bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.longName : NSLocalizedString("unknown", comment: "Unknown")
|
||||
let buttonText = String.localizedStringWithFormat(NSLocalizedString("save.config %@", comment: "Save Config for %@"), nodeName)
|
||||
Button(buttonText) {
|
||||
let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral?.num ?? -1, context: context)
|
||||
if hasChanges {
|
||||
var cmc = ModuleConfig.CannedMessageConfig()
|
||||
cmc.enabled = enabled
|
||||
cmc.sendBell = sendBell
|
||||
cmc.rotary1Enabled = rotary1Enabled
|
||||
cmc.updown1Enabled = updown1Enabled
|
||||
if rotary1Enabled {
|
||||
/// Input event origin accepted by the canned messages
|
||||
/// Can be e.g. "rotEnc1", "upDownEnc1", "cardkb", or keyword "_any"
|
||||
cmc.allowInputSource = "rotEnc1"
|
||||
} else if updown1Enabled {
|
||||
cmc.allowInputSource = "upDown1"
|
||||
} else {
|
||||
cmc.allowInputSource = "_any"
|
||||
}
|
||||
cmc.inputbrokerPinA = UInt32(inputbrokerPinA)
|
||||
cmc.inputbrokerPinB = UInt32(inputbrokerPinB)
|
||||
cmc.inputbrokerPinPress = UInt32(inputbrokerPinPress)
|
||||
cmc.inputbrokerEventCw = InputEventChars(rawValue: inputbrokerEventCw)!.protoEnumValue()
|
||||
cmc.inputbrokerEventCcw = InputEventChars(rawValue: inputbrokerEventCcw)!.protoEnumValue()
|
||||
cmc.inputbrokerEventPress = InputEventChars(rawValue: inputbrokerEventPress)!.protoEnumValue()
|
||||
let adminMessageId = bleManager.saveCannedMessageModuleConfig(config: cmc, fromUser: node!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
|
||||
if adminMessageId > 0 {
|
||||
// Should show a saved successfully alert once I know that to be true
|
||||
// for now just disable the button after a successful save
|
||||
hasChanges = false
|
||||
goBack()
|
||||
if connectedNode != nil {
|
||||
var cmc = ModuleConfig.CannedMessageConfig()
|
||||
cmc.enabled = enabled
|
||||
cmc.sendBell = sendBell
|
||||
cmc.rotary1Enabled = rotary1Enabled
|
||||
cmc.updown1Enabled = updown1Enabled
|
||||
if rotary1Enabled {
|
||||
/// Input event origin accepted by the canned messages
|
||||
/// Can be e.g. "rotEnc1", "upDownEnc1", "cardkb", or keyword "_any"
|
||||
cmc.allowInputSource = "rotEnc1"
|
||||
} else if updown1Enabled {
|
||||
cmc.allowInputSource = "upDown1"
|
||||
} else {
|
||||
cmc.allowInputSource = "_any"
|
||||
}
|
||||
cmc.inputbrokerPinA = UInt32(inputbrokerPinA)
|
||||
cmc.inputbrokerPinB = UInt32(inputbrokerPinB)
|
||||
cmc.inputbrokerPinPress = UInt32(inputbrokerPinPress)
|
||||
cmc.inputbrokerEventCw = InputEventChars(rawValue: inputbrokerEventCw)!.protoEnumValue()
|
||||
cmc.inputbrokerEventCcw = InputEventChars(rawValue: inputbrokerEventCcw)!.protoEnumValue()
|
||||
cmc.inputbrokerEventPress = InputEventChars(rawValue: inputbrokerEventPress)!.protoEnumValue()
|
||||
let adminMessageId = bleManager.saveCannedMessageModuleConfig(config: cmc, fromUser: node!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
|
||||
if adminMessageId > 0 {
|
||||
// Should show a saved successfully alert once I know that to be true
|
||||
// for now just disable the button after a successful save
|
||||
hasChanges = false
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
if hasMessagesChanges {
|
||||
let adminMessageId = bleManager.saveCannedMessageModuleMessages(messages: messages, fromUser: node!.user!, toUser: node!.user!, adminIndex: node?.myInfo?.adminIndex ?? 0)
|
||||
let adminMessageId = bleManager.saveCannedMessageModuleMessages(messages: messages, fromUser: node!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
|
||||
if adminMessageId > 0 {
|
||||
// Should show a saved successfully alert once I know that to be true
|
||||
// for now just disable the button after a successful save
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue