From dc97948f9b9d5f3e1627b503c22bd76b7ae67474 Mon Sep 17 00:00:00 2001 From: Ryan Nystrom Date: Tue, 9 Oct 2018 21:28:34 -0400 Subject: [PATCH] always call completion block when early returning b/c of bg --- Classes/Notifications/NotificationModelController.swift | 6 +++++- .../View Controllers/SplitViewControllerDelegate.swift | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Classes/Notifications/NotificationModelController.swift b/Classes/Notifications/NotificationModelController.swift index b581b951e..c0549a946 100644 --- a/Classes/Notifications/NotificationModelController.swift +++ b/Classes/Notifications/NotificationModelController.swift @@ -52,7 +52,11 @@ final class NotificationModelController { completion: @escaping (Result<([NotificationViewModel], Int?)>) -> Void ) { // hack to prevent double-fetching notifications when awaking from bg fetch - guard UIApplication.shared.applicationState != .background else { return } + guard UIApplication.shared.applicationState != .background else { + // return success to avoid error states + completion(.success(([], nil))) + return + } let badge = githubClient.badge let contentSizeCategory = UIContentSizeCategory.preferred diff --git a/Classes/View Controllers/SplitViewControllerDelegate.swift b/Classes/View Controllers/SplitViewControllerDelegate.swift index d94ecabe6..d60e704de 100644 --- a/Classes/View Controllers/SplitViewControllerDelegate.swift +++ b/Classes/View Controllers/SplitViewControllerDelegate.swift @@ -31,11 +31,16 @@ final class SplitViewControllerDelegate: UISplitViewControllerDelegate { let primaryNav = tab.selectedViewController as? UINavigationController, let secondaryNav = secondaryViewController as? UINavigationController { - // remove any placeholder VCs from the stack - primaryNav.viewControllers += secondaryNav.viewControllers.filter { + let collapsedControllers = secondaryNav.viewControllers.filter { $0.hidesBottomBarWhenPushed = true + // remove any placeholder VCs from the stack return ($0 is SplitPlaceholderViewController) == false } + // avoid setting view controllers b/c can result in viewDidLoad being called + // https://github.com/GitHawkApp/GitHawk/issues/2230 + if collapsedControllers.count > 0 { + primaryNav.viewControllers += collapsedControllers + } } return true