perferredPeripheralId fix

This commit is contained in:
Jake-B 2025-11-01 16:45:02 -04:00
parent b4c749a978
commit b327f13971

View file

@ -66,15 +66,6 @@ extension AccessoryManager {
Logger.transport.info("[Accessory] Event stream closed")
}
self.activeConnection = (device: device, connection: connection)
// if we don't have a peripheralId, set it now at the beginning of the
// connect process (because I think it is used in other parts of the app
// during the connect process?
// Otherwise, UserDefault.preferredPeripheralId is set in the Connect
// view, as part of the "Connect to new radio?" confirmation dialog logic.
if UserDefaults.preferredPeripheralId.isEmpty {
UserDefaults.preferredPeripheralId = device.id.uuidString
}
} catch let error as CBError where error.code == .peerRemovedPairingInformation {
await self.connectionStepper?.cancelCurrentlyExecutingStep(withError: AccessoryError.coreBluetoothError(error), cancelFullProcess: true)
}
@ -119,6 +110,10 @@ extension AccessoryManager {
Logger.transport.info("🔗👟 [Connect] Step 5: Send wantConfig (database)")
self.updateState(.retrievingDatabase(nodeCount: 0))
self.allowDisconnect = true
Logger.transport.info("🔗 Saving preferredPeripheralId: \(device.id.uuidString)")
UserDefaults.preferredPeripheralId = device.id.uuidString
try await self.sendWantDatabase()
}