Shows “Downloading [app]…” toast view when installing app from new source

Allows users to tap it to immediately see installation progress.
This commit is contained in:
Riley Testut
2024-02-14 17:43:36 -06:00
committed by Magesh K
parent 74a231242e
commit 846285eb1f
2 changed files with 37 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ extension AppManager
static let didUpdatePatronsNotification = Notification.Name("io.altstore.AppManager.didUpdatePatrons")
static let didAddSourceNotification = Notification.Name("io.altstore.AppManager.didAddSource")
static let didRemoveSourceNotification = Notification.Name("io.altstore.AppManager.didRemoveSource")
static let willInstallAppFromNewSourceNotification = Notification.Name("io.altstore.AppManager.willInstallAppFromNewSource")
static let expirationWarningNotificationID = "altstore-expiration-warning"
static let enableJITResultNotificationID = "altstore-enable-jit"
@@ -405,6 +406,7 @@ extension AppManager
completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) async -> RefreshGroup
{
@AsyncManaged var installingApp: AppProtocol = app
var didAddSource = false
do
{
@@ -446,6 +448,8 @@ extension AppManager
guard let storeApp = try DatabaseManager.shared.viewContext.fetch(fetchRequest).first else { throw OperationError.appNotFound(name: appName) }
return storeApp
}
didAddSource = true
}
}
catch
@@ -458,6 +462,15 @@ extension AppManager
}
let group = await $installingApp.perform { self.install($0, presentingViewController: presentingViewController, context: context, completionHandler: completionHandler) }
if didAddSource
{
// Post notification from main queue _after_ assigning progress for it
await MainActor.run { [installingApp] in
NotificationCenter.default.post(name: AppManager.willInstallAppFromNewSourceNotification, object: installingApp)
}
}
return group
}
}