Push Notification Live Activity Redundancy
Nucleic-Session: 73687ED9-C11C-438C-832B-979332B73893 Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
@@ -293,14 +293,20 @@ final class LiveActivityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Hand the newest state to the serial drainer (starting it if idle).
|
/// 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
|
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
|
guard updateTask == nil else { return } // the running drainer will pick this up
|
||||||
updateTask = Task { @MainActor [weak self] in
|
updateTask = Task { @MainActor [weak self] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
while let next = self.pendingState {
|
while let next = self.pendingState {
|
||||||
self.pendingState = nil
|
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
|
self.updateTask = nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user