Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Ben Meadors 2025-07-07 10:49:52 -05:00 committed by GitHub
parent d51b8887ee
commit 30d150e3aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -499,7 +499,11 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
let traceRoute = TraceRouteEntity(context: context)
let nodes = NodeInfoEntity.fetchRequest()
nodes.predicate = NSPredicate(format: "num IN %@", [destNum, self.connectedPeripheral?.num ?? 0])
if let connectedNum = self.connectedPeripheral?.num {
nodes.predicate = NSPredicate(format: "num IN %@", [destNum, connectedNum])
} else {
nodes.predicate = NSPredicate(format: "num == %@", destNum)
}
do {
let fetchedNodes = try context.fetch(nodes)
let receivingNode = fetchedNodes.first(where: { $0.num == destNum })