From e8b7446117455399f7670573ad5d685a0e67bf8a Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 22 Jan 2023 14:01:44 -0500 Subject: [PATCH] Fix split view expand breaking when transferring trending statuses/hashtags/links VCs --- Tusker/Screens/Main/MainSplitViewController.swift | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Tusker/Screens/Main/MainSplitViewController.swift b/Tusker/Screens/Main/MainSplitViewController.swift index 1e9c0b86..95dcb590 100644 --- a/Tusker/Screens/Main/MainSplitViewController.swift +++ b/Tusker/Screens/Main/MainSplitViewController.swift @@ -277,6 +277,7 @@ extension MainSplitViewController: UISplitViewControllerDelegate { case .explore: // The Explore tab is more complicated since it encapsulates a bunch of screens which have top-level sidebar items. + var skipFirst = 1 var toPrepend: UIViewController? = nil // If the tab navigation stack has only one item or the search controller is active, it corresponds to the Search item @@ -308,19 +309,17 @@ extension MainSplitViewController: UISplitViewControllerDelegate { exploreItem = .savedHashtag(hashtagVC.hashtag) case let instanceVC as InstanceTimelineViewController: exploreItem = .savedInstance(instanceVC.instanceURL) - case is TrendingStatusesViewController: - exploreItem = .explore - case is TrendingHashtagsViewController: - exploreItem = .explore - case is TrendingLinksViewController: + case is TrendingStatusesViewController, is TrendingHashtagsViewController, is TrendingLinksViewController: exploreItem = .explore + // these three VCs are part of the root SearchViewController, so we don't need to transfer them + skipFirst = 2 case is ProfileDirectoryViewController: exploreItem = .profileDirectory default: fatalError("unhandled second-level explore screen: \(tabNavigationStack[1])") } } - transferNavigationStack(from: tabNavController, to: exploreItem!, skipFirst: 1, prepend: toPrepend) + transferNavigationStack(from: tabNavController, to: exploreItem!, skipFirst: skipFirst, prepend: toPrepend) case .compose: // The compose tab can't be activated, this is unreachable.