Skip to content

Commit

Permalink
Fix Inspecting ViewController on non-main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
cocojoe committed Oct 22, 2019
1 parent cddd38b commit 180b585
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Auth0/SafariWebAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,15 @@ class SafariWebAuth: WebAuth {
}

let finish: (Result<Credentials>) -> Void = { [weak controller] (result: Result<Credentials>) -> Void in
guard let presenting = controller?.presentingViewController else {
return callback(Result.failure(error: WebAuthError.cannotDismissWebAuthController))
}

if case .failure(let cause as WebAuthError) = result, case .userCancelled = cause {
DispatchQueue.main.async {
callback(result)
}
} else {
DispatchQueue.main.async {
guard let presenting = controller?.presentingViewController else {
return callback(Result.failure(error: WebAuthError.cannotDismissWebAuthController))
}
presenting.dismiss(animated: true) {
callback(result)
}
Expand Down

0 comments on commit 180b585

Please sign in to comment.