diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index b4b508f0..aaa664ff 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -1304,12 +1304,12 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate return 0 } - public func saveChannelSet(base64UrlString: String, addChannel: Bool = false) -> Bool { + public func saveChannelSet(base64UrlString: String, addChannels: Bool = false) -> Bool { if isConnected { var i: Int32 = 0 // Before we get started delete the existing channels from the myNodeInfo - if !addChannel { + if !addChannels { tryClearExistingChannels() } else { // We are trying to add a channel so lets get the last index @@ -1318,7 +1318,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate do { let fetchedMyInfo = try context?.fetch(fetchMyInfoRequest) as? [MyInfoEntity] ?? [] if fetchedMyInfo.count == 1 { - if addChannel { + if addChannels { i = Int32(fetchedMyInfo[0].channels?.count ?? -1) // Bail out if the index is negative or bigger than our max of 8 if i < 0 || i > 8 { diff --git a/Meshtastic/MeshtasticApp.swift b/Meshtastic/MeshtasticApp.swift index 765969d4..aeb6488c 100644 --- a/Meshtastic/MeshtasticApp.swift +++ b/Meshtastic/MeshtasticApp.swift @@ -18,7 +18,7 @@ struct MeshtasticAppleApp: App { @State var saveChannels = false @State var incomingUrl: URL? @State var channelSettings: String? - @State var addChannel = false + @State var addChannels = false @StateObject var appState = AppState.shared var body: some Scene { @@ -27,7 +27,7 @@ struct MeshtasticAppleApp: App { .environment(\.managedObjectContext, persistenceController.container.viewContext) .environmentObject(bleManager) .sheet(isPresented: $saveChannels) { - SaveChannelQRCode(channelSetLink: channelSettings ?? "Empty Channel URL", addChannel: addChannel, bleManager: bleManager) + SaveChannelQRCode(channelSetLink: channelSettings ?? "Empty Channel URL", addChannels: addChannels, bleManager: bleManager) .presentationDetents([.medium, .large]) .presentationDragIndicator(.visible) } @@ -42,8 +42,8 @@ struct MeshtasticAppleApp: App { return } self.channelSettings = cs - self.addChannel = Bool(self.incomingUrl?["add"] ?? "false") ?? false - print("Add Channel \(self.addChannel)") + self.addChannels = Bool(self.incomingUrl?["add"] ?? "false") ?? false + print("Add Channel \(self.addChannels)") } self.saveChannels = true print("User wants to open a Channel Settings URL: \(self.incomingUrl?.absoluteString ?? "No QR Code Link")") diff --git a/Meshtastic/Views/Settings/SaveChannelQRCode.swift b/Meshtastic/Views/Settings/SaveChannelQRCode.swift index a44e9e01..f9ca2557 100644 --- a/Meshtastic/Views/Settings/SaveChannelQRCode.swift +++ b/Meshtastic/Views/Settings/SaveChannelQRCode.swift @@ -11,23 +11,23 @@ struct SaveChannelQRCode: View { @Environment(\.dismiss) private var dismiss var channelSetLink: String - var addChannel: Bool = false + var addChannels: Bool = false var bleManager: BLEManager @State var connectedToDevice = false var body: some View { VStack { - Text("Save Channel Settings?") + Text("\(addChannels ? "Add" : "Replace all") Channels?") .font(.title) - Text("These settings will replace the current LoRa Config and Channel Settings on your radio. After everything saves your device will reboot.") + Text("These settings will \(addChannels ? "add" : "replace all") channels. The current LoRa Config will be replaced. After everything saves your device will reboot.") .foregroundColor(.gray) - .font(.callout) + .font(.title3) .padding() HStack { Button { - let success = bleManager.saveChannelSet(base64UrlString: channelSetLink, addChannel: addChannel) + let success = bleManager.saveChannelSet(base64UrlString: channelSetLink, addChannels: addChannels) if success { dismiss() }