Return to main queue after getting notified of the dispatch group completion. Fixes #2863

This commit is contained in:
Maurice Parker 2021-03-09 04:23:19 -06:00
parent c9807a6bb0
commit 64e5a09ac6
1 changed files with 16 additions and 14 deletions

View File

@ -310,20 +310,22 @@ final class CloudKitAccountDelegate: AccountDelegate {
}
group.notify(queue: DispatchQueue.global(qos: .background)) {
guard !errorOccurred else {
self.refreshProgress.completeTask()
completion(.failure(CloudKitAccountDelegateError.unknown))
return
}
self.accountZone.removeFolder(folder) { result in
self.refreshProgress.completeTask()
switch result {
case .success:
account.removeFolder(folder)
completion(.success(()))
case .failure(let error):
completion(.failure(error))
DispatchQueue.main.async {
guard !errorOccurred else {
self.refreshProgress.completeTask()
completion(.failure(CloudKitAccountDelegateError.unknown))
return
}
self.accountZone.removeFolder(folder) { result in
self.refreshProgress.completeTask()
switch result {
case .success:
account.removeFolder(folder)
completion(.success(()))
case .failure(let error):
completion(.failure(error))
}
}
}
}