mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Clean up canned messages a bit more
This commit is contained in:
parent
82fc62fc84
commit
4c5c2eae43
2 changed files with 15 additions and 24 deletions
|
|
@ -78,8 +78,10 @@ struct CannedMessagesConfig: View {
|
|||
messages = String(messages.dropLast())
|
||||
totalBytes = messages.utf8.count
|
||||
}
|
||||
hasMessagesChanges = true
|
||||
hasChanges = true
|
||||
if messages != node?.cannedMessageConfig?.messages ?? "" {
|
||||
hasChanges = true
|
||||
hasMessagesChanges = true
|
||||
}
|
||||
}
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
|
|
@ -202,6 +204,11 @@ struct CannedMessagesConfig: View {
|
|||
cmc.inputbrokerEventCw = InputEventChars(rawValue: inputbrokerEventCw)!.protoEnumValue()
|
||||
cmc.inputbrokerEventCcw = InputEventChars(rawValue: inputbrokerEventCcw)!.protoEnumValue()
|
||||
cmc.inputbrokerEventPress = InputEventChars(rawValue: inputbrokerEventPress)!.protoEnumValue()
|
||||
let messagesAdminMessageId = bleManager.saveCannedMessageModuleMessages(messages: messages, fromUser: node!.user!, toUser: node!.user!)
|
||||
if messagesAdminMessageId > 0 {
|
||||
// Fire off the message update ever time
|
||||
hasMessagesChanges = false
|
||||
}
|
||||
let adminMessageId = bleManager.saveCannedMessageModuleConfig(config: cmc, fromUser: node!.user!, toUser: node!.user!)
|
||||
if adminMessageId > 0 {
|
||||
// Should show a saved successfully alert once I know that to be true
|
||||
|
|
@ -211,18 +218,6 @@ struct CannedMessagesConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
if hasMessagesChanges {
|
||||
let adminMessageId = bleManager.saveCannedMessageModuleMessages(messages: messages, fromUser: node!.user!, toUser: node!.user!)
|
||||
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
|
||||
hasMessagesChanges = false
|
||||
if !hasChanges {
|
||||
bleManager.sendWantConfig()
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Canned Messages Config")
|
||||
.navigationBarItems(
|
||||
|
|
|
|||
|
|
@ -216,15 +216,11 @@ struct UserConfig: View {
|
|||
self.overrideFrequency = node?.loRaConfig?.overrideFrequency ?? 0.00
|
||||
self.hasChanges = false
|
||||
}
|
||||
.onChange(of: shortName) { _, newShort in
|
||||
if node != nil && node!.user != nil {
|
||||
if newShort != node?.user!.shortName { hasChanges = true }
|
||||
}
|
||||
.onChange(of: shortName) { oldShort, newShort in
|
||||
if oldShort != newShort && newShort != node?.user?.shortName ?? "Unknown" { hasChanges = true }
|
||||
}
|
||||
.onChange(of: longName) { _, newLong in
|
||||
if node != nil && node!.user != nil {
|
||||
if newLong != node?.user!.longName { hasChanges = true }
|
||||
}
|
||||
.onChange(of: longName) { oldLong, newLong in
|
||||
if oldLong != newLong && newLong != node?.user?.longName ?? "Unknown" { hasChanges = true }
|
||||
}
|
||||
.onChange(of: isLicensed) { _, newIsLicensed in
|
||||
if node != nil && node!.user != nil {
|
||||
|
|
@ -239,10 +235,10 @@ struct UserConfig: View {
|
|||
}
|
||||
}
|
||||
.onChange(of: overrideFrequency) {
|
||||
hasChanges = true
|
||||
if isLicensed { hasChanges = true }
|
||||
}
|
||||
.onChange(of: txPower) {
|
||||
hasChanges = true
|
||||
if isLicensed { hasChanges = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue