mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-20 12:13:26 +01:00
Refines AppManager Combine pipeline
This commit is contained in:
@@ -76,16 +76,19 @@ class AppManager
|
|||||||
@available(iOS 13, *)
|
@available(iOS 13, *)
|
||||||
func prepareSubscriptions()
|
func prepareSubscriptions()
|
||||||
{
|
{
|
||||||
|
/// Every time refreshProgress is changed, update all InstalledApps in memory
|
||||||
|
/// so that app.isRefreshing == refreshProgress.keys.contains(app.bundleID)
|
||||||
|
|
||||||
self.publisher.$refreshProgress
|
self.publisher.$refreshProgress
|
||||||
.receive(on: RunLoop.main)
|
.receive(on: RunLoop.main)
|
||||||
.map(\.keys)
|
.map(\.keys)
|
||||||
.flatMap { (bundleIDs) in
|
.flatMap { (bundleIDs) in
|
||||||
DatabaseManager.shared.viewContext.registeredObjects.publisher
|
DatabaseManager.shared.viewContext.registeredObjects.publisher
|
||||||
.compactMap { $0 as? InstalledApp }
|
.compactMap { $0 as? InstalledApp }
|
||||||
.map { ($0, bundleIDs) }
|
.map { ($0, bundleIDs.contains($0.bundleIdentifier)) }
|
||||||
}
|
}
|
||||||
.sink { (installedApp, bundleIDs) in
|
.sink { (installedApp, isRefreshing) in
|
||||||
installedApp.isRefreshing = bundleIDs.contains(installedApp.bundleIdentifier)
|
installedApp.isRefreshing = isRefreshing
|
||||||
}
|
}
|
||||||
.store(in: &self.cancellables)
|
.store(in: &self.cancellables)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user