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

Proper fix to prevent double fetching from background #2279

Merged
merged 1 commit into from
Oct 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Classes/Notifications/NotificationModelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ final class NotificationModelController {
width: CGFloat,
completion: @escaping (Result<([NotificationViewModel], Int?)>) -> Void
) {
// hack to prevent double-fetching notifications when awaking from bg fetch
guard UIApplication.shared.applicationState != .background else {
// return success to avoid error states
completion(.success(([], nil)))
return
}

let badge = githubClient.badge
let contentSizeCategory = UIContentSizeCategory.preferred
// TODO move handling + parsing to a single method?
Expand Down
5 changes: 4 additions & 1 deletion Classes/Systems/Feed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ final class Feed: NSObject, UIScrollViewDelegate {

view.backgroundColor = .white

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

adapter.collectionView = collectionView

Expand Down