Skip to content

Commit 3baa7d6

Browse files
committed
draft additional property observation fix
1 parent 2eaa267 commit 3baa7d6

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Sources/FoundationEssentials/ProgressManager/ProgressManager+Properties+Accessors.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,15 +541,17 @@ extension ProgressManager {
541541
/// - Parameter property: The `TotalFileCount` property type.
542542
/// - Returns: The sum of all total file counts across the entire progress subtree.
543543
public func summary(of property: ProgressManager.Properties.TotalFileCount.Type) -> Int {
544-
return getUpdatedFileCount(type: .total)
544+
// return getUpdatedFileCount(type: .total)
545+
return totalFileCount
545546
}
546547

547548
/// Returns the completed file count across the progress subtree.
548549
///
549550
/// - Parameter property: The `CompletedFileCount` property type.
550551
/// - Returns: The sum of all completed file counts across the entire progress subtree.
551552
public func summary(of property: ProgressManager.Properties.CompletedFileCount.Type) -> Int {
552-
return getUpdatedFileCount(type: .completed)
553+
// return getUpdatedFileCount(type: .completed)
554+
return completedFileCount
553555
}
554556

555557
/// Returns the total byte count across the progress subtree.

Sources/FoundationEssentials/ProgressManager/ProgressManager.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ internal import _FoundationCollections
185185
}
186186
}
187187

188+
//MARK: Internal vars to make additional properties observable
189+
internal var totalFileCount: Int {
190+
_$observationRegistrar.access(self, keyPath: \.totalFileCount)
191+
return getUpdatedFileCount(type: .total)
192+
}
193+
194+
internal var completedFileCount: Int {
195+
_$observationRegistrar.access(self, keyPath: \.completedFileCount)
196+
return getUpdatedFileCount(type: .completed)
197+
}
198+
188199
//MARK: Fractional Properties Methods
189200
internal func getProgressFraction() -> ProgressFraction {
190201
return state.withLock { state in

0 commit comments

Comments
 (0)