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