Fix assorted issues collapsing/expanding split VC
This commit is contained in:
parent
9fc4aa8a40
commit
ee651ae96a
|
@ -225,6 +225,7 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
|
|||
// so that explore items aren't shown multiple times.
|
||||
|
||||
let exploreNav = tabBarViewController.viewController(for: .explore) as! UINavigationController
|
||||
// make sure there's a root ExploreViewController
|
||||
let explore: ExploreViewController
|
||||
if let existing = exploreNav.viewControllers.first as? ExploreViewController {
|
||||
explore = existing
|
||||
|
@ -238,14 +239,23 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
|
|||
explore.loadViewIfNeeded()
|
||||
|
||||
let search = secondaryNavController.viewControllers.first as! InlineTrendsViewController
|
||||
// Copy the search query from the search VC to the Explore VC's search controller.
|
||||
let query = search.searchController.searchBar.text ?? ""
|
||||
explore.searchController.searchBar.text = query
|
||||
// Instruct the explore controller to show its search controller immediately upon its first appearance.
|
||||
// explore.searchController.isActive can't be set directly, see FB7814561
|
||||
explore.searchControllerStatusOnAppearance = !query.isEmpty
|
||||
// Copy the results from the search VC's results controller to avoid the delay introduced by an extra network request
|
||||
explore.resultsController.loadResults(from: search.resultsController)
|
||||
if search.searchController.isActive {
|
||||
// Copy the search query from the search VC to the Explore VC's search controller.
|
||||
let query = search.searchController.searchBar.text ?? ""
|
||||
explore.searchController.searchBar.text = query
|
||||
// Instruct the explore controller to show its search controller immediately upon its first appearance.
|
||||
// explore.searchController.isActive can't be set directly, see FB7814561
|
||||
explore.searchControllerStatusOnAppearance = !query.isEmpty
|
||||
// Copy the results from the search VC's results controller to avoid the delay introduced by an extra network request
|
||||
explore.resultsController.loadResults(from: search.resultsController)
|
||||
} else {
|
||||
// if there is more than just the InlineTrendsVC, and the search VC is not active,
|
||||
// then the user selected something from the trends screen
|
||||
if secondaryNavController.viewControllers.count >= 2 {
|
||||
// make sure there's a corresponding trends VC in the collapsed nav that they can go back to
|
||||
exploreNav.pushViewController(TrendsViewController(mastodonController: mastodonController), animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
// Transfer the navigation stack, dropping the search VC, to keep anything the user has opened
|
||||
transferNavigationStack(from: .explore, to: exploreNav, dropFirst: true, append: true)
|
||||
|
@ -329,14 +339,16 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
|
|||
exploreItem = .favorites
|
||||
case let listVC as ListTimelineViewController:
|
||||
exploreItem = .list(listVC.list)
|
||||
case let hashtagVC as HashtagTimelineViewController:
|
||||
case let hashtagVC as HashtagTimelineViewController where hashtagVC.isHashtagSaved:
|
||||
exploreItem = .savedHashtag(hashtagVC.hashtag)
|
||||
case let instanceVC as InstanceTimelineViewController:
|
||||
exploreItem = .savedInstance(instanceVC.instanceURL)
|
||||
case is TrendingStatusesViewController, is TrendingHashtagsViewController, is TrendingLinksViewController:
|
||||
case is TrendsViewController:
|
||||
exploreItem = .explore
|
||||
// these three VCs are part of the root SearchViewController, so we don't need to transfer them
|
||||
// skip transferring the ExploreViewController and TrendsViewController
|
||||
skipFirst = 2
|
||||
// prepend the InlineTrendsViewController
|
||||
toPrepend = getOrCreateNavigationStack(item: .explore).first!
|
||||
default:
|
||||
// transfer the navigation stack prepending, the existing explore VC
|
||||
// if there was other stuff on the explore stack, it will get discarded
|
||||
|
|
|
@ -15,7 +15,7 @@ class HashtagTimelineViewController: TimelineViewController {
|
|||
|
||||
var toggleSaveButton: UIBarButtonItem!
|
||||
|
||||
private var isHashtagSaved: Bool {
|
||||
var isHashtagSaved: Bool {
|
||||
let req = SavedHashtag.fetchRequest(name: hashtag.name, account: mastodonController.accountInfo!)
|
||||
return mastodonController.persistentContainer.viewContext.objectExists(for: req)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue