diff --git a/AltStore/App Detail/AppViewController.swift b/AltStore/App Detail/AppViewController.swift index 1ea05cea..ad866fc1 100644 --- a/AltStore/App Detail/AppViewController.swift +++ b/AltStore/App Detail/AppViewController.swift @@ -346,7 +346,7 @@ private extension AppViewController if let installedApp = self.app.installedApp { - if let latestVersion = self.app.latestAvailableVersion, !installedApp.matches(latestVersion) + if let latestVersion = self.app.latestSupportedVersion, !installedApp.matches(latestVersion) { button.setTitle(NSLocalizedString("UPDATE", comment: ""), for: .normal) } @@ -364,7 +364,7 @@ private extension AppViewController button.progress = progress } - if let versionDate = self.app.latestAvailableVersion?.date, versionDate > Date() + if let versionDate = self.app.latestSupportedVersion?.date, versionDate > Date() { self.bannerView.button.countdownDate = versionDate self.navigationBarDownloadButton.countdownDate = versionDate @@ -500,7 +500,7 @@ extension AppViewController { if let installedApp = self.app.installedApp { - if let latestVersion = self.app.latestAvailableVersion, !installedApp.matches(latestVersion) + if let latestVersion = self.app.latestSupportedVersion, !installedApp.matches(latestVersion) { self.updateApp(installedApp) } @@ -562,7 +562,7 @@ extension AppViewController return } - _ = AppManager.shared.update(installedApp, to: .latestAvailableVersionWithFallback, presentingViewController: self) { (result) in + _ = AppManager.shared.update(installedApp, presentingViewController: self) { (result) in DispatchQueue.main.async { switch result { diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index 5893e0b8..d29f2773 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -25,12 +25,6 @@ extension AppManager static let expirationWarningNotificationID = "altstore-expiration-warning" static let enableJITResultNotificationID = "altstore-enable-jit" - - enum PreferredAppVersion - { - case latestSupportedVersion - case latestAvailableVersionWithFallback - } } class AppManagerPublisher: ObservableObject @@ -545,16 +539,9 @@ extension AppManager } @discardableResult - func update(_ installedApp: InstalledApp, to preferredAppVersion: PreferredAppVersion = .latestSupportedVersion, presentingViewController: UIViewController?, context: AuthenticatedOperationContext = AuthenticatedOperationContext(), completionHandler: @escaping (Result) -> Void) -> Progress + func update(_ installedApp: InstalledApp, presentingViewController: UIViewController?, context: AuthenticatedOperationContext = AuthenticatedOperationContext(), completionHandler: @escaping (Result) -> Void) -> Progress { - let preferredApp: AppProtocol? - 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 { + guard let appVersion = installedApp.storeApp?.latestSupportedVersion else { completionHandler(.failure(OperationError.appNotFound(name: installedApp.name))) return Progress.discreteProgress(totalUnitCount: 1) } @@ -572,7 +559,7 @@ extension AppManager } } - let operation = AppOperation.update(app) + let operation = AppOperation.update(appVersion) assert(operation.app as AnyObject !== installedApp) // Make sure we never accidentally "update" to already installed app. self.perform([operation], presentingViewController: presentingViewController, group: group)