From e8f676b10b7b28033961391918e5a4ec3ea3642f Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 18 May 2023 17:44:54 -0500 Subject: [PATCH] =?UTF-8?q?Fixes=20showing=20=E2=80=9CUpdate=E2=80=9D=20bu?= =?UTF-8?q?tton=20on=20app=20store=20page=20when=20no=20supported=20update?= =?UTF-8?q?=20is=20available?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AltStore/App Detail/AppViewController.swift | 8 ++++---- AltStore/Managing Apps/AppManager.swift | 19 +++---------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/AltStore/App Detail/AppViewController.swift b/AltStore/App Detail/AppViewController.swift index ddf19ec9..0c8f87e9 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) } @@ -561,7 +561,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 b303bc45..920a4411 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -27,12 +27,6 @@ extension AppManager static let expirationWarningNotificationID = "altstore-expiration-warning" static let enableJITResultNotificationID = "altstore-enable-jit" - - enum PreferredAppVersion - { - case latestSupportedVersion - case latestAvailableVersionWithFallback - } } @available(iOS 13, *) @@ -558,16 +552,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) } @@ -585,7 +572,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)