From 9ece114f7a56b4e4d525d8d749c9b6c55872a3c8 Mon Sep 17 00:00:00 2001 From: Magesh K <47920326+mahee96@users.noreply.github.com> Date: Sat, 28 Dec 2024 02:12:03 +0530 Subject: [PATCH] [Fix]: operate on UI controls in main thread --- .../Operations/AuthenticationOperation.swift | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/AltStore/Operations/AuthenticationOperation.swift b/AltStore/Operations/AuthenticationOperation.swift index 7c84de34..730edd11 100644 --- a/AltStore/Operations/AuthenticationOperation.swift +++ b/AltStore/Operations/AuthenticationOperation.swift @@ -555,26 +555,26 @@ private extension AuthenticationOperation } } - let alertController = UIAlertController(title: NSLocalizedString("Would you like to revoke your previous certificates?\n\(certsText)", comment: ""), message: nil, preferredStyle: .alert) - - let noAction = UIAlertAction(title: NSLocalizedString("No", comment: ""), style: .default) { (action) in - requestCertificate() - } - let yesAction = UIAlertAction(title: NSLocalizedString("Yes", comment: ""), style: .default) { (action) in - for certificate in ourCertificates { - ALTAppleAPI.shared.revoke(certificate, for: team, session: session) { (success, error) in - if let error = error, !success - { - completionHandler(.failure(error)) + DispatchQueue.main.async { + let alertController = UIAlertController(title: NSLocalizedString("Would you like to revoke your previous certificates?\n\(certsText)", comment: ""), message: nil, preferredStyle: .alert) + + let noAction = UIAlertAction(title: NSLocalizedString("No", comment: ""), style: .default) { (action) in + requestCertificate() + } + let yesAction = UIAlertAction(title: NSLocalizedString("Yes", comment: ""), style: .default) { (action) in + for certificate in ourCertificates { + ALTAppleAPI.shared.revoke(certificate, for: team, session: session) { (success, error) in + if let error = error, !success + { + completionHandler(.failure(error)) + } } } + requestCertificate() } - requestCertificate() - } - alertController.addAction(noAction) - alertController.addAction(yesAction) - - DispatchQueue.main.async { + alertController.addAction(noAction) + alertController.addAction(yesAction) + if self.navigationController.presentingViewController != nil { self.navigationController.present(alertController, animated: true, completion: nil)