mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 19:53:25 +01:00
fix: Refreshing via Xcode would cause a crash here
This commit is contained in:
@@ -1015,11 +1015,18 @@ private extension AppManager
|
|||||||
return group
|
return group
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeAppExtensions(from application: ALTApplication, existingApp: InstalledApp?, extensions: Set<ALTApplication>, _ presentingViewController: UIViewController?, completion: @escaping (Result<Void, Error>) -> Void)
|
func removeAppExtensions(
|
||||||
{
|
from application: ALTApplication,
|
||||||
|
existingApp: InstalledApp?,
|
||||||
|
extensions: Set<ALTApplication>,
|
||||||
|
_ presentingViewController: UIViewController?,
|
||||||
|
completion: @escaping (Result<Void, Error>) -> Void
|
||||||
|
) {
|
||||||
|
|
||||||
//App-Extensions: Ensure existing app's extensions and currently installing app's extensions must match
|
// App-Extensions: Ensure existing app's extensions and currently installing app's extensions must match
|
||||||
let existingAppEx: Set<InstalledExtension> = existingApp?.appExtensions ?? Set()
|
if let existingApp {
|
||||||
|
_ = RSTAsyncBlockOperation { _ in
|
||||||
|
let existingAppEx: Set<InstalledExtension> = existingApp.appExtensions
|
||||||
let currentAppEx: Set<ALTApplication> = application.appExtensions
|
let currentAppEx: Set<ALTApplication> = application.appExtensions
|
||||||
|
|
||||||
let currentAppExNames = currentAppEx.map{ appEx in appEx.bundleIdentifier}
|
let currentAppExNames = currentAppEx.map{ appEx in appEx.bundleIdentifier}
|
||||||
@@ -1029,11 +1036,13 @@ private extension AppManager
|
|||||||
!(existingAppExNames.contains($0.bundleIdentifier))
|
!(existingAppExNames.contains($0.bundleIdentifier))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let isMatching = (currentAppEx.count == existingAppEx.count) && excessExtensions.isEmpty
|
let isMatching = (currentAppEx.count == existingAppEx.count) && excessExtensions.isEmpty
|
||||||
let diagnosticsMsg = "AppManager.removeAppExtensions: App Extensions in existingApp and currentApp are matching: \(isMatching)\n"
|
let diagnosticsMsg = "AppManager.removeAppExtensions: App Extensions in existingApp and currentApp are matching: \(isMatching)\n"
|
||||||
+ "AppManager.removeAppExtensions: existingAppEx: \(existingAppExNames); currentAppEx: \(String(describing: currentAppExNames))\n"
|
+ "AppManager.removeAppExtensions: existingAppEx: \(existingAppExNames); currentAppEx: \(String(describing: currentAppExNames))\n"
|
||||||
print(diagnosticsMsg)
|
print(diagnosticsMsg)
|
||||||
|
|
||||||
|
|
||||||
// if background mode, then remove only the excess extensions
|
// if background mode, then remove only the excess extensions
|
||||||
guard let presentingViewController: UIViewController = presentingViewController else {
|
guard let presentingViewController: UIViewController = presentingViewController else {
|
||||||
// perform silent extensions cleanup for those that aren't already present in existing app
|
// perform silent extensions cleanup for those that aren't already present in existing app
|
||||||
@@ -1050,9 +1059,12 @@ private extension AppManager
|
|||||||
return completion(.failure(error))
|
return completion(.failure(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
guard !application.appExtensions.isEmpty else { return completion(.success(())) }
|
guard !application.appExtensions.isEmpty else { return completion(.success(())) }
|
||||||
|
|
||||||
|
DispatchQueue.main.async {
|
||||||
let firstSentence: String
|
let firstSentence: String
|
||||||
|
|
||||||
if UserDefaults.standard.activeAppLimitIncludesExtensions
|
if UserDefaults.standard.activeAppLimitIncludesExtensions
|
||||||
@@ -1090,6 +1102,7 @@ private extension AppManager
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if let presentingViewController {
|
||||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("Choose App Extensions", comment: ""), style: .default) { (action) in
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("Choose App Extensions", comment: ""), style: .default) { (action) in
|
||||||
let popoverContentController = AppExtensionViewHostingController(extensions: extensions) { (selection) in
|
let popoverContentController = AppExtensionViewHostingController(extensions: extensions) { (selection) in
|
||||||
do
|
do
|
||||||
@@ -1119,18 +1132,14 @@ private extension AppManager
|
|||||||
popoverPresentationController.sourceRect = CGRect(x: 50, y: 50, width: 4, height: 4)
|
popoverPresentationController.sourceRect = CGRect(x: 50, y: 50, width: 4, height: 4)
|
||||||
popoverPresentationController.delegate = popoverContentController
|
popoverPresentationController.delegate = popoverContentController
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
presentingViewController.present(popoverContentController, animated: true)
|
presentingViewController.present(popoverContentController, animated: true)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
presentingViewController.present(alertController, animated: true)
|
presentingViewController.present(alertController, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func _install(_ app: AppProtocol, operation appOperation: AppOperation, group: RefreshGroup, context: InstallAppOperationContext? = nil, additionalEntitlements: [ALTEntitlement: Any]? = nil, cacheApp: Bool = true, completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) -> Progress
|
private func _install(_ app: AppProtocol, operation appOperation: AppOperation, group: RefreshGroup, context: InstallAppOperationContext? = nil, additionalEntitlements: [ALTEntitlement: Any]? = nil, cacheApp: Bool = true, completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) -> Progress
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user