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 2b816fee4b
commit 2dd475e71d
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))
}
}
}
}