Skip to content

Commit

Permalink
LiveActivity update optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Nov 22, 2024
1 parent 42cc780 commit 0f82fe5
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ private extension LiveActivityService {

@available(iOS 16.1, *)
func update(_ activity: Activity<ProgressWidgetAttributes>, with state: ProgressWidgetAttributes.ContentState) async {
if #available(iOS 16.2, *) {
guard activity.content.state != state
else { return }
} else {
guard activity.contentState != state
else { return }
}

if let date = throttleMap[activity.attributes.hash],
Int(Date.now.timeIntervalSince(date)) <= Self.throttleDuration
{ return }
Expand Down

0 comments on commit 0f82fe5

Please sign in to comment.