From e005b70071cad825d01ff3af93061bc493d5b90a Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 30 Nov 2022 16:33:39 -0500 Subject: [PATCH] Fix creating list on iPad not showing Edit List screen immediately --- Tusker/Screens/Lists/ListTimelineViewController.swift | 2 +- Tusker/Screens/Main/MainSidebarViewController.swift | 6 +++++- Tusker/Screens/Main/MainSplitViewController.swift | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Lists/ListTimelineViewController.swift b/Tusker/Screens/Lists/ListTimelineViewController.swift index d4010ea3..5c1c83cf 100644 --- a/Tusker/Screens/Lists/ListTimelineViewController.swift +++ b/Tusker/Screens/Lists/ListTimelineViewController.swift @@ -48,7 +48,7 @@ class ListTimelineViewController: TimelineViewController { super.viewDidAppear(animated) if presentEditOnAppear { - presentEdit(animated: animated) + presentEdit(animated: true) presentEditOnAppear = false } } diff --git a/Tusker/Screens/Main/MainSidebarViewController.swift b/Tusker/Screens/Main/MainSidebarViewController.swift index c336387d..98b63dfa 100644 --- a/Tusker/Screens/Main/MainSidebarViewController.swift +++ b/Tusker/Screens/Main/MainSidebarViewController.swift @@ -13,6 +13,7 @@ import Combine protocol MainSidebarViewControllerDelegate: AnyObject { func sidebarRequestPresentCompose(_ sidebarViewController: MainSidebarViewController) func sidebar(_ sidebarViewController: MainSidebarViewController, didSelectItem item: MainSidebarViewController.Item) + func sidebar(_ sidebarViewController: MainSidebarViewController, showViewController viewController: UIViewController) } class MainSidebarViewController: UIViewController { @@ -281,7 +282,10 @@ class MainSidebarViewController: UIViewController { private func showAddList() { let service = CreateListService(mastodonController: mastodonController, present: { self.present($0, animated: true ) }) { list in - self.sidebarDelegate?.sidebar(self, didSelectItem: .list(list)) + self.select(item: .list(list), animated: false) + let list = ListTimelineViewController(for: list, mastodonController: self.mastodonController) + list.presentEditOnAppear = true + self.sidebarDelegate?.sidebar(self, showViewController: list) } service.run() } diff --git a/Tusker/Screens/Main/MainSplitViewController.swift b/Tusker/Screens/Main/MainSplitViewController.swift index 2d6bd512..68fda5b3 100644 --- a/Tusker/Screens/Main/MainSplitViewController.swift +++ b/Tusker/Screens/Main/MainSplitViewController.swift @@ -358,6 +358,13 @@ extension MainSplitViewController: MainSidebarViewControllerDelegate { } select(item: item) } + + func sidebar(_ sidebarViewController: MainSidebarViewController, showViewController viewController: UIViewController) { + if let previous = sidebar.previouslySelectedItem { + navigationStacks[previous] = secondaryNavController.viewControllers + } + secondaryNavController.viewControllers = [viewController] + } } fileprivate extension MainSidebarViewController.Item {