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

Commit 119139a

Browse files
authored
always call completion block when early returning b/c of bg (#2258)
1 parent 2c55fc2 commit 119139a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Classes/Notifications/NotificationModelController.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ final class NotificationModelController {
5252
completion: @escaping (Result<([NotificationViewModel], Int?)>) -> Void
5353
) {
5454
// hack to prevent double-fetching notifications when awaking from bg fetch
55-
guard UIApplication.shared.applicationState != .background else { return }
55+
guard UIApplication.shared.applicationState != .background else {
56+
// return success to avoid error states
57+
completion(.success(([], nil)))
58+
return
59+
}
5660

5761
let badge = githubClient.badge
5862
let contentSizeCategory = UIContentSizeCategory.preferred

Classes/View Controllers/SplitViewControllerDelegate.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@ final class SplitViewControllerDelegate: UISplitViewControllerDelegate {
3131
let primaryNav = tab.selectedViewController as? UINavigationController,
3232
let secondaryNav = secondaryViewController as? UINavigationController {
3333

34-
// remove any placeholder VCs from the stack
35-
primaryNav.viewControllers += secondaryNav.viewControllers.filter {
34+
let collapsedControllers = secondaryNav.viewControllers.filter {
3635
$0.hidesBottomBarWhenPushed = true
36+
// remove any placeholder VCs from the stack
3737
return ($0 is SplitPlaceholderViewController) == false
3838
}
39+
// avoid setting view controllers b/c can result in viewDidLoad being called
40+
// https://github.com/GitHawkApp/GitHawk/issues/2230
41+
if collapsedControllers.count > 0 {
42+
primaryNav.viewControllers += collapsedControllers
43+
}
3944
}
4045

4146
return true

0 commit comments

Comments
 (0)