Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion OpenHaystack/OpenHaystack/FindMy/FindMyController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ class FindMyController: ObservableObject {

let accessQueue = DispatchQueue(label: "threadSafeAccess", qos: .userInitiated, attributes: .concurrent, autoreleaseFrequency: .workItem, target: nil)
var decryptedReports = [FindMyLocationReport](repeating: FindMyLocationReport(lat: 0, lng: 0, acc: 0, dP: Date(), t: Date(), c: 0), count: reports.count)
var failedDecryptIndexes = [Int]()
DispatchQueue.concurrentPerform(iterations: reports.count) { (reportIdx) in
let report = reports[reportIdx]
guard let key = keyMap[report.id] else { return }
Expand All @@ -215,11 +216,16 @@ class FindMyController: ObservableObject {
decryptedReports[reportIdx] = locationReport
}
} catch {
return
accessQueue.async(flags: .barrier) {
failedDecryptIndexes.append(reportIdx)
}
}
}

accessQueue.sync {
for index in failedDecryptIndexes.sorted(by: { $0 > $1 }) {
decryptedReports.remove(at: index)
}
devices[deviceIdx].decryptedReports = decryptedReports
}
}
Expand Down