From 4b42bc257dfeefd3cb5f4aa62c95cd3174cbda8f Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 25 Jun 2024 18:55:43 -0700 Subject: [PATCH] Connect view cleanup --- Meshtastic/Views/Bluetooth/Connect.swift | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Meshtastic/Views/Bluetooth/Connect.swift b/Meshtastic/Views/Bluetooth/Connect.swift index b831c544..9da6f8f2 100644 --- a/Meshtastic/Views/Bluetooth/Connect.swift +++ b/Meshtastic/Views/Bluetooth/Connect.swift @@ -214,7 +214,6 @@ struct Connect: View { if let connectedPeripheral = bleManager.connectedPeripheral, connectedPeripheral.peripheral.state == CBPeripheralState.connected { bleManager.disconnectPeripheral() } - // clearCoreDataDatabase(context: context, includeRoutes: false) let container = NSPersistentContainer(name: "Meshtastic") guard let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { Logger.data.error("nil File path for back") @@ -223,17 +222,13 @@ struct Connect: View { do { try container.copyPersistentStores(to: url.appendingPathComponent("backup").appendingPathComponent("\(UserDefaults.preferredPeripheralNum)"), overwriting: true) Logger.data.notice("🗂️ Made a core data backup to backup/\(UserDefaults.preferredPeripheralNum)") + clearCoreDataDatabase(context: context, includeRoutes: true) } catch { Logger.data.error("🗂️ Core data backup copy error: \(error, privacy: .public)") } - UserDefaults.preferredPeripheralId = selectedPeripherialId - let radio = bleManager.peripherals.first(where: { $0.peripheral.identifier.uuidString == selectedPeripherialId }) - if radio != nil { - bleManager.connectTo(peripheral: radio!.peripheral) - } - } else { - self.bleManager.connectTo(peripheral: peripheral.peripheral) } + UserDefaults.preferredPeripheralId = selectedPeripherialId + self.bleManager.connectTo(peripheral: peripheral.peripheral) }) { Text(peripheral.name).font(.callout) }