mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-13 00:33:28 +01:00
Updates UI when refreshing apps with Siri
This commit is contained in:
@@ -10,6 +10,8 @@ import Foundation
|
||||
import UIKit
|
||||
import UserNotifications
|
||||
import MobileCoreServices
|
||||
import Intents
|
||||
import Combine
|
||||
|
||||
import AltStoreCore
|
||||
import AltSign
|
||||
@@ -22,15 +24,41 @@ extension AppManager
|
||||
static let expirationWarningNotificationID = "altstore-expiration-warning"
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
class AppManagerPublisher: ObservableObject
|
||||
{
|
||||
@Published
|
||||
fileprivate(set) var installationProgress = [String: Progress]()
|
||||
|
||||
@Published
|
||||
fileprivate(set) var refreshProgress = [String: Progress]()
|
||||
}
|
||||
|
||||
class AppManager
|
||||
{
|
||||
static let shared = AppManager()
|
||||
|
||||
@available(iOS 13, *)
|
||||
private(set) lazy var publisher: AppManagerPublisher = AppManagerPublisher()
|
||||
|
||||
private let operationQueue = OperationQueue()
|
||||
private let serialOperationQueue = OperationQueue()
|
||||
|
||||
private var installationProgress = [String: Progress]() {
|
||||
didSet {
|
||||
guard #available(iOS 13, *) else { return }
|
||||
self.publisher.installationProgress = self.installationProgress
|
||||
}
|
||||
}
|
||||
private var refreshProgress = [String: Progress]() {
|
||||
didSet {
|
||||
guard #available(iOS 13, *) else { return }
|
||||
self.publisher.refreshProgress = self.refreshProgress
|
||||
}
|
||||
}
|
||||
|
||||
private var installationProgress = [String: Progress]()
|
||||
private var refreshProgress = [String: Progress]()
|
||||
@available(iOS 13.0, *)
|
||||
private lazy var cancellables = Set<AnyCancellable>()
|
||||
|
||||
private init()
|
||||
{
|
||||
@@ -38,6 +66,28 @@ class AppManager
|
||||
|
||||
self.serialOperationQueue.name = "com.altstore.AppManager.serialOperationQueue"
|
||||
self.serialOperationQueue.maxConcurrentOperationCount = 1
|
||||
|
||||
if #available(iOS 13, *)
|
||||
{
|
||||
self.prepareSubscriptions()
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
func prepareSubscriptions()
|
||||
{
|
||||
self.publisher.$refreshProgress
|
||||
.receive(on: RunLoop.main)
|
||||
.map(\.keys)
|
||||
.flatMap { (bundleIDs) in
|
||||
DatabaseManager.shared.viewContext.registeredObjects.publisher
|
||||
.compactMap { $0 as? InstalledApp }
|
||||
.map { ($0, bundleIDs) }
|
||||
}
|
||||
.sink { (installedApp, bundleIDs) in
|
||||
installedApp.isRefreshing = bundleIDs.contains(installedApp.bundleIdentifier)
|
||||
}
|
||||
.store(in: &self.cancellables)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user