diff --git a/Meshtastic/Views/Bluetooth/Connect.swift b/Meshtastic/Views/Bluetooth/Connect.swift index 6b8cda7e..b27dbaa0 100644 --- a/Meshtastic/Views/Bluetooth/Connect.swift +++ b/Meshtastic/Views/Bluetooth/Connect.swift @@ -181,7 +181,25 @@ struct Connect: View { } }.padding([.bottom, .top]) } - }.textCase(nil) + } + .confirmationDialog("Connecting to a new radio will clear all local app data on the phone.", isPresented: $presentingSwitchPreferredPeripheral, titleVisibility: .visible) { + + Button("Connect to new radio?", role: .destructive) { + bleManager.stopScanning() + bleManager.connectedPeripheral = nil + userSettings.preferredPeripheralId = "" + if bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.peripheral.state == CBPeripheralState.connected { + bleManager.disconnectPeripheral() + } + + clearCoreDataDatabase(context: context) + let radio = bleManager.peripherals.first(where: { $0.peripheral.identifier.uuidString == selectedPeripherialId} ) + bleManager.connectTo(peripheral: radio!.peripheral) + presentingSwitchPreferredPeripheral = false + selectedPeripherialId = "" + } + } + .textCase(nil) } } else { @@ -190,23 +208,6 @@ struct Connect: View { .font(.title) } } - .confirmationDialog("Connecting to a new radio will clear all local app data on the phone.", isPresented: $presentingSwitchPreferredPeripheral, titleVisibility: .visible) { - - Button("Connect to new radio?", role: .destructive) { - bleManager.stopScanning() - bleManager.connectedPeripheral = nil - userSettings.preferredPeripheralId = "" - if bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.peripheral.state == CBPeripheralState.connected { - bleManager.disconnectPeripheral() - } - - clearCoreDataDatabase(context: context) - let radio = bleManager.peripherals.first(where: { $0.peripheral.identifier.uuidString == selectedPeripherialId} ) - bleManager.connectTo(peripheral: radio!.peripheral) - presentingSwitchPreferredPeripheral = false - selectedPeripherialId = "" - } - } HStack(alignment: .center) { Spacer()