Live Activity Content Density
Nucleic-Session: B3643133-163C-4C5D-BE20-1A6B7FB83DA9 Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
@@ -17,6 +17,17 @@ final class LiveActivityManager {
|
|||||||
|
|
||||||
private var activity: Activity<NucleicSessionAttributes>?
|
private var activity: Activity<NucleicSessionAttributes>?
|
||||||
|
|
||||||
|
/// The last content we pushed. Updates that don't change it are skipped so we don't spend
|
||||||
|
/// ActivityKit's update budget on no-ops — `sync` fires on every host message (dashboard,
|
||||||
|
/// connectivity, pong, diff ticks…), most of which leave the aggregate identical. Burning the
|
||||||
|
/// budget on those is exactly what makes a *real* change land late and the glance read stale.
|
||||||
|
private var lastState: NucleicSessionAttributes.ContentState?
|
||||||
|
/// The newest state waiting to be applied, and the single task draining it. Coalescing to the
|
||||||
|
/// latest through one serial task means the newest data always wins — firing an unstructured
|
||||||
|
/// `Task` per `sync` let a later update lose a race to an earlier one and freeze the glance.
|
||||||
|
private var pendingState: NucleicSessionAttributes.ContentState?
|
||||||
|
private var updateTask: Task<Void, Never>?
|
||||||
|
|
||||||
/// Reconcile the Activity with the current session set.
|
/// Reconcile the Activity with the current session set.
|
||||||
func sync(hostName: String, sessions: [WireSessionSummary]) {
|
func sync(hostName: String, sessions: [WireSessionSummary]) {
|
||||||
guard ActivityAuthorizationInfo().areActivitiesEnabled else { return }
|
guard ActivityAuthorizationInfo().areActivitiesEnabled else { return }
|
||||||
|
|||||||
Reference in New Issue
Block a user