Skip to content

Commit 2694f82

Browse files
committed
Reduce unecessary background pressure on fetch event
1 parent b1ce696 commit 2694f82

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

Sources/App/AppDelegate.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -206,20 +206,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
206206
_ application: UIApplication,
207207
performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
208208
) {
209-
let timestamp = DateFormatter.localizedString(from: Date(), dateStyle: .medium, timeStyle: .full)
210-
Current.Log.verbose("Background fetch activated at \(timestamp)!")
211-
212-
DataWidgetsUpdater.update()
213-
214-
#if !targetEnvironment(macCatalyst)
215-
if UIDevice.current.userInterfaceIdiom == .phone, case .paired = Communicator.shared.currentWatchState {
216-
Current.Log.verbose("Requesting watch sync from background fetch")
217-
Communicator.shared.send(GuaranteedMessage(identifier: GuaranteedMessages.sync.rawValue)) { error in
218-
Current.Log.error("Failed to request watch sync from background fetch: \(error)")
219-
}
220-
}
221-
#endif
222-
209+
Current.clientEventStore.addEvent(ClientEvent(text: "Background fetch activated", type: .backgroundOperation))
223210
Current.backgroundTask(withName: "background-fetch") { remaining in
224211
let updatePromise: Promise<Void>
225212
if Current.settingsStore.isLocationEnabled(for: UIApplication.shared.applicationState),

Sources/Shared/ClientEvents/Model/ClientEvent.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public struct ClientEvent: Codable, FetchableRecord, PersistableRecord {
1515
case networkRequest
1616
case settings
1717
case database
18+
case backgroundOperation
1819
case unknown
1920
}
2021

0 commit comments

Comments
 (0)