mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 19:53:25 +01:00
Updates UI when refreshing apps with Siri
This commit is contained in:
@@ -10,6 +10,8 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import UserNotifications
|
import UserNotifications
|
||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
|
import Intents
|
||||||
|
import Combine
|
||||||
|
|
||||||
import AltStoreCore
|
import AltStoreCore
|
||||||
import AltSign
|
import AltSign
|
||||||
@@ -22,15 +24,41 @@ extension AppManager
|
|||||||
static let expirationWarningNotificationID = "altstore-expiration-warning"
|
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
|
class AppManager
|
||||||
{
|
{
|
||||||
static let shared = AppManager()
|
static let shared = AppManager()
|
||||||
|
|
||||||
|
@available(iOS 13, *)
|
||||||
|
private(set) lazy var publisher: AppManagerPublisher = AppManagerPublisher()
|
||||||
|
|
||||||
private let operationQueue = OperationQueue()
|
private let operationQueue = OperationQueue()
|
||||||
private let serialOperationQueue = 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]()
|
@available(iOS 13.0, *)
|
||||||
private var refreshProgress = [String: Progress]()
|
private lazy var cancellables = Set<AnyCancellable>()
|
||||||
|
|
||||||
private init()
|
private init()
|
||||||
{
|
{
|
||||||
@@ -38,6 +66,28 @@ class AppManager
|
|||||||
|
|
||||||
self.serialOperationQueue.name = "com.altstore.AppManager.serialOperationQueue"
|
self.serialOperationQueue.name = "com.altstore.AppManager.serialOperationQueue"
|
||||||
self.serialOperationQueue.maxConcurrentOperationCount = 1
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="16119" systemVersion="19G73" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17189" systemVersion="20A5354i" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||||
<entity name="Account" representedClassName="Account" syncable="YES">
|
<entity name="Account" representedClassName="Account" syncable="YES">
|
||||||
<attribute name="appleID" attributeType="String"/>
|
<attribute name="appleID" attributeType="String"/>
|
||||||
<attribute name="firstName" attributeType="String"/>
|
<attribute name="firstName" attributeType="String"/>
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
<attribute name="expirationDate" attributeType="Date" usesScalarValueType="NO"/>
|
<attribute name="expirationDate" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
<attribute name="installedDate" attributeType="Date" usesScalarValueType="NO"/>
|
<attribute name="installedDate" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
<attribute name="isActive" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/>
|
<attribute name="isActive" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="isRefreshing" transient="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||||
<attribute name="name" attributeType="String"/>
|
<attribute name="name" attributeType="String"/>
|
||||||
<attribute name="refreshedDate" attributeType="Date" usesScalarValueType="NO"/>
|
<attribute name="refreshedDate" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
<attribute name="resignedBundleIdentifier" attributeType="String"/>
|
<attribute name="resignedBundleIdentifier" attributeType="String"/>
|
||||||
@@ -162,7 +163,7 @@
|
|||||||
<element name="Account" positionX="-36" positionY="90" width="128" height="135"/>
|
<element name="Account" positionX="-36" positionY="90" width="128" height="135"/>
|
||||||
<element name="AppID" positionX="-27" positionY="153" width="128" height="133"/>
|
<element name="AppID" positionX="-27" positionY="153" width="128" height="133"/>
|
||||||
<element name="AppPermission" positionX="-45" positionY="90" width="128" height="90"/>
|
<element name="AppPermission" positionX="-45" positionY="90" width="128" height="90"/>
|
||||||
<element name="InstalledApp" positionX="-63" positionY="0" width="128" height="223"/>
|
<element name="InstalledApp" positionX="-63" positionY="0" width="128" height="224"/>
|
||||||
<element name="InstalledExtension" positionX="-45" positionY="135" width="128" height="163"/>
|
<element name="InstalledExtension" positionX="-45" positionY="135" width="128" height="163"/>
|
||||||
<element name="NewsItem" positionX="-45" positionY="126" width="128" height="238"/>
|
<element name="NewsItem" positionX="-45" positionY="126" width="128" height="238"/>
|
||||||
<element name="PatreonAccount" positionX="-45" positionY="117" width="128" height="105"/>
|
<element name="PatreonAccount" positionX="-45" positionY="117" width="128" height="105"/>
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ public class InstalledApp: NSManagedObject, InstalledAppProtocol
|
|||||||
|
|
||||||
@NSManaged public var certificateSerialNumber: String?
|
@NSManaged public var certificateSerialNumber: String?
|
||||||
|
|
||||||
|
/* Transient */
|
||||||
|
@NSManaged public var isRefreshing: Bool
|
||||||
|
|
||||||
/* Relationships */
|
/* Relationships */
|
||||||
@NSManaged public var storeApp: StoreApp?
|
@NSManaged public var storeApp: StoreApp?
|
||||||
@NSManaged public var team: Team?
|
@NSManaged public var team: Team?
|
||||||
|
|||||||
Reference in New Issue
Block a user