krz/domain-dig
an ios app for DNS & SSL analysis
clone: git clone https://gitbay.org/krz/domain-dig.git
v5.0.2: Shared/SweepActivityAttributes.swift · raw
1import ActivityKit
2import Foundation
3
4/// Live Activity contract for an in-flight watchlist sweep or batch lookup.
5///
6/// Lives in `Shared/` because the app starts/updates the activity and the
7/// widget extension renders it. Explicitly `nonisolated`: the app target sets
8/// `SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor`, which would otherwise infer a
9/// main-actor-isolated `ActivityAttributes` conformance that ActivityKit cannot
10/// use from its concurrent contexts.
11nonisolated struct SweepActivityAttributes: ActivityAttributes {
12 struct ContentState: Codable, Hashable {
13 var completed: Int
14 var total: Int
15 var currentDomain: String?
16 var changed: Int
17 var warnings: Int
18
19 var fractionComplete: Double {
20 guard total > 0 else { return 0 }
21 return Double(completed) / Double(total)
22 }
23 }
24
25 /// User-facing title for the run, e.g. "Watchlist Sweep" or "Batch Lookup".
26 var title: String
27 var startedAt: Date
28}