Skip to content

Commit

Permalink
VIT-7771: Fix deprioritized resources not making forward progress in …
Browse files Browse the repository at this point in the history
…some environments
  • Loading branch information
andersio committed Nov 8, 2024
1 parent 2d9129c commit 6ac3e0a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Sources/VitalHealthKit/HealthKit/AppStateTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ final class AppStateTracker {

@objc
func appDidFinishLaunching() {
if UIApplication.shared.applicationState == .background {
transition(to: .background)
DispatchQueue.main.async {
self.powerStateDidChange()
}
}

Expand All @@ -74,7 +74,8 @@ final class AppStateTracker {

@objc
func powerStateDidChange() {
transition(to: UIApplication.shared.applicationState == .background ? .background : .foreground)
let state = UIApplication.shared.applicationState
transition(to: state == .background ? .background : .foreground)
}

func transition(to newStatus: AppState.Status) {
Expand Down
4 changes: 3 additions & 1 deletion Sources/VitalHealthKit/HealthKit/VitalHealthKitClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,9 @@ extension VitalHealthKitClient {
// OR has no sync attempt
// OR has errored
let lastStatus = resourceProgress.latestSync?.lastStatus
return lastStatus == nil || lastStatus == .error || lastStatus == .cancelled || lastStatus == .timedOut

return lastStatus == nil || lastStatus == .error || lastStatus == .cancelled
|| lastStatus == .timedOut || lastStatus == .started || lastStatus == .deprioritized
}

// Rescue these resources
Expand Down

0 comments on commit 6ac3e0a

Please sign in to comment.