Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 0db4c23

Browse files
authored
Proper fix to prevent double fetching from background (#2279)
1 parent 5b3ec76 commit 0db4c23

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Classes/Notifications/NotificationModelController.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,6 @@ final class NotificationModelController {
5151
width: CGFloat,
5252
completion: @escaping (Result<([NotificationViewModel], Int?)>) -> Void
5353
) {
54-
// hack to prevent double-fetching notifications when awaking from bg fetch
55-
guard UIApplication.shared.applicationState != .background else {
56-
// return success to avoid error states
57-
completion(.success(([], nil)))
58-
return
59-
}
60-
6154
let badge = githubClient.badge
6255
let contentSizeCategory = UIContentSizeCategory.preferred
6356
// TODO move handling + parsing to a single method?

Classes/Systems/Feed.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ final class Feed: NSObject, UIScrollViewDelegate {
7676

7777
view.backgroundColor = .white
7878

79-
refresh()
79+
// avoid app launch in the background triggering viewDidLoad-based network calls
80+
if UIApplication.shared.applicationState != .background {
81+
refresh()
82+
}
8083

8184
adapter.collectionView = collectionView
8285

0 commit comments

Comments
 (0)