mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 19:53:25 +01:00
Fixes updating apps to latest version instead of latest supported version from My Apps tab
This commit is contained in:
@@ -27,6 +27,12 @@ extension AppManager
|
|||||||
|
|
||||||
static let expirationWarningNotificationID = "altstore-expiration-warning"
|
static let expirationWarningNotificationID = "altstore-expiration-warning"
|
||||||
static let enableJITResultNotificationID = "altstore-enable-jit"
|
static let enableJITResultNotificationID = "altstore-enable-jit"
|
||||||
|
|
||||||
|
enum PreferredAppVersion
|
||||||
|
{
|
||||||
|
case latestSupportedVersion
|
||||||
|
case latestAvailableVersionWithFallback
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS 13, *)
|
@available(iOS 13, *)
|
||||||
@@ -499,10 +505,17 @@ extension AppManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
func update(_ app: InstalledApp, presentingViewController: UIViewController?, context: AuthenticatedOperationContext = AuthenticatedOperationContext(), completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) -> Progress
|
func update(_ installedApp: InstalledApp, to preferredAppVersion: PreferredAppVersion = .latestSupportedVersion, presentingViewController: UIViewController?, context: AuthenticatedOperationContext = AuthenticatedOperationContext(), completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) -> Progress
|
||||||
{
|
{
|
||||||
guard let storeApp = app.storeApp else {
|
let preferredApp: AppProtocol?
|
||||||
completionHandler(.failure(OperationError.appNotFound(name: app.name)))
|
switch preferredAppVersion
|
||||||
|
{
|
||||||
|
case .latestSupportedVersion: preferredApp = installedApp.storeApp?.latestSupportedVersion
|
||||||
|
case .latestAvailableVersionWithFallback: preferredApp = installedApp.storeApp // Use StoreApp directly to correctly handle min/max OS versions in DownloadAppOperation.
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let app = preferredApp else {
|
||||||
|
completionHandler(.failure(OperationError.appNotFound(name: installedApp.name)))
|
||||||
return Progress.discreteProgress(totalUnitCount: 1)
|
return Progress.discreteProgress(totalUnitCount: 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,8 +532,8 @@ extension AppManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let operation = AppOperation.update(storeApp)
|
let operation = AppOperation.update(app)
|
||||||
assert(operation.app as AnyObject === storeApp) // Make sure we never accidentally "update" to already installed app.
|
assert(operation.app as AnyObject !== installedApp) // Make sure we never accidentally "update" to already installed app.
|
||||||
|
|
||||||
self.perform([operation], presentingViewController: presentingViewController, group: group)
|
self.perform([operation], presentingViewController: presentingViewController, group: group)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user