Push Notification Live Activity Redundancy

Nucleic-Session: 73687ED9-C11C-438C-832B-979332B73893
Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
2026-07-06 21:33:38 -07:00
co-authored by Nucleic
parent f62840f276
commit 9300340475
@@ -293,14 +293,20 @@ final class LiveActivityManager {
}
/// Hand the newest state to the serial drainer (starting it if idle).
private func enqueue(_ state: NucleicSessionAttributes.ContentState) {
private func enqueue(
_ state: NucleicSessionAttributes.ContentState, alert: AlertConfiguration? = nil
) {
pendingState = state
if let alert { pendingAlert = alert } // latch — a coalesced-away update must not drop it
guard updateTask == nil else { return } // the running drainer will pick this up
updateTask = Task { @MainActor [weak self] in
guard let self else { return }
while let next = self.pendingState {
self.pendingState = nil
await self.activity?.update(ActivityContent(state: next, staleDate: nil))
let alert = self.pendingAlert
self.pendingAlert = nil
await self.activity?.update(
ActivityContent(state: next, staleDate: nil), alertConfiguration: alert)
}
self.updateTask = nil
}