[AltStore] Update apps from UpdatesViewController

This commit is contained in:
Riley Testut
2019-06-17 14:49:23 -07:00
parent 9538d05f9f
commit d65cef8817
10 changed files with 231 additions and 30 deletions

View File

@@ -14,6 +14,11 @@ import AltKit
import Roxas
extension AppManager
{
static let didFetchAppsNotification = Notification.Name("com.altstore.AppManager.didFetchApps")
}
class AppManager
{
static let shared = AppManager()
@@ -75,6 +80,26 @@ extension AppManager
}
}
extension AppManager
{
func fetchApps(completionHandler: @escaping (Result<[App], Error>) -> Void)
{
let fetchAppsOperation = FetchAppsOperation()
fetchAppsOperation.resultHandler = { (result) in
switch result
{
case .failure(let error):
completionHandler(.failure(error))
case .success(let apps):
completionHandler(.success(apps))
NotificationCenter.default.post(name: AppManager.didFetchAppsNotification, object: self)
}
}
self.operationQueue.addOperation(fetchAppsOperation)
}
}
extension AppManager
{
func install(_ app: App, presentingViewController: UIViewController, completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) -> Progress