Don't unnecessarily load views when transferring navigation stacks

This commit is contained in:
Shadowfacts 2020-12-14 22:24:48 -05:00
parent c7b708e62b
commit 1b44117891
1 changed files with 5 additions and 2 deletions

View File

@ -139,7 +139,9 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
// Transfer the nav stacks for all the sidebar items that map 1 <-> 1 with tabs
for tab in [MainTabBarViewController.Tab.timelines, .notifications, .myProfile] {
let tabNav = tabBarViewController.viewController(for: tab) as! UINavigationController
transferNavigationStack(from: .tab(tab), to: tabNav)
if tabNav.isViewLoaded {
transferNavigationStack(from: .tab(tab), to: tabNav)
}
}
// Since several sidebar items map to the single Explore tab, we only transfer the
@ -235,7 +237,8 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
// For each sidebar item, transfer the existing navigation stasck from the tab bar controller to ourself.
var exploreItem: MainSidebarViewController.Item?
for tab in MainTabBarViewController.Tab.allCases {
guard let tabNavController = tabBarViewController.viewController(for: tab) as? UINavigationController else { continue }
guard let tabNavController = tabBarViewController.viewController(for: tab) as? UINavigationController,
tabNavController.isViewLoaded else { continue }
let tabNavigationStack = tabNavController.viewControllers
switch tab {