Do CloudKit record process loop on a high priority background thread so that it doesn't block the main thread
This commit is contained in:
parent
b77e2164cd
commit
ac9ba39ea2
|
@ -132,8 +132,12 @@ private extension CloudKitArticlesZoneDelegate {
|
||||||
group.leave()
|
group.leave()
|
||||||
}
|
}
|
||||||
|
|
||||||
let parsedItems = records.compactMap { makeParsedItem($0) }
|
group.enter()
|
||||||
|
DispatchQueue.global(qos: .userInitiated).async {
|
||||||
|
let parsedItems = records.compactMap { self.makeParsedItem($0) }
|
||||||
let webFeedIDsAndItems = Dictionary(grouping: parsedItems, by: { item in item.feedURL } ).mapValues { Set($0) }
|
let webFeedIDsAndItems = Dictionary(grouping: parsedItems, by: { item in item.feedURL } ).mapValues { Set($0) }
|
||||||
|
|
||||||
|
DispatchQueue.main.async {
|
||||||
for (webFeedID, parsedItems) in webFeedIDsAndItems {
|
for (webFeedID, parsedItems) in webFeedIDsAndItems {
|
||||||
group.enter()
|
group.enter()
|
||||||
self.account?.update(webFeedID, with: parsedItems, deleteOlder: false) { result in
|
self.account?.update(webFeedID, with: parsedItems, deleteOlder: false) { result in
|
||||||
|
@ -153,6 +157,10 @@ private extension CloudKitArticlesZoneDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
group.leave()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
group.notify(queue: DispatchQueue.main) {
|
group.notify(queue: DispatchQueue.main) {
|
||||||
if errorOccurred {
|
if errorOccurred {
|
||||||
|
|
Loading…
Reference in New Issue