Make DownloadProgress and CombinedRefreshProgress MainActor.

This commit is contained in:
Brent Simmons 2024-04-01 22:12:05 -07:00
parent 83a067bda7
commit 1c9452a1c5
3 changed files with 5 additions and 7 deletions

View File

@ -119,7 +119,7 @@ private extension CloudKitSendStatusOperation {
return CloudKitArticleStatusUpdate(articleID: key, statuses: value, article: articlesDict[key])
}
@Sendable func done(_ stop: Bool) {
@MainActor func done(_ stop: Bool) {
// Don't clear the last one since we might have had additional ticks added
if self.showProgress && self.refreshProgress?.numberRemaining ?? 0 > 1 {
self.refreshProgress?.completeTask()

View File

@ -12,7 +12,7 @@ import Web
// Combines the refresh progress of multiple accounts into one struct,
// for use by refresh status view and so on.
public struct CombinedRefreshProgress {
@MainActor public struct CombinedRefreshProgress {
public let numberOfTasks: Int
public let numberRemaining: Int

View File

@ -8,14 +8,12 @@
import Foundation
// Main thread only.
public extension Notification.Name {
static let DownloadProgressDidChange = Notification.Name(rawValue: "DownloadProgressDidChange")
}
public final class DownloadProgress {
@MainActor public final class DownloadProgress {
public var numberOfTasks = 0 {
didSet {
@ -94,9 +92,9 @@ public final class DownloadProgress {
// MARK: - Private
private extension DownloadProgress {
func postDidChangeNotification() {
DispatchQueue.main.async {
Task { @MainActor in
NotificationCenter.default.post(name: .DownloadProgressDidChange, object: self)
}
}