diff --git a/WordPress/Classes/System/RootViewPresenter.swift b/WordPress/Classes/System/RootViewPresenter.swift index b3c51697dd88..3a5cc05ab8ed 100644 --- a/WordPress/Classes/System/RootViewPresenter.swift +++ b/WordPress/Classes/System/RootViewPresenter.swift @@ -6,11 +6,11 @@ protocol RootViewPresenter: AnyObject { var rootViewController: UIViewController { get } func currentlySelectedScreen() -> String - func currentlyVisibleBlog() -> Blog? // MARK: Sites var mySitesCoordinator: MySitesCoordinator { get } + func currentlyVisibleBlog() -> Blog? func showBlogDetails(for blog: Blog, then subsection: BlogDetailsSubsection?, userInfo: [AnyHashable: Any]) func showMySitesTab() diff --git a/WordPress/Classes/System/SplitViewRootPresenter.swift b/WordPress/Classes/System/SplitViewRootPresenter.swift index e2d56edd2cc2..22b8244ec588 100644 --- a/WordPress/Classes/System/SplitViewRootPresenter.swift +++ b/WordPress/Classes/System/SplitViewRootPresenter.swift @@ -240,27 +240,24 @@ final class SplitViewRootPresenter: RootViewPresenter { var rootViewController: UIViewController { splitVC } - // MARK: RootViewPresenter (Sites) - func currentlySelectedScreen() -> String { if splitVC.isCollapsed { return tabBarViewController.currentlySelectedScreen() } else { switch sidebarViewModel.selection { - case .welcome: - return "Welcome" - case .blog: - return WPTabBarCurrentlySelectedScreenSites - case .notifications: - return WPTabBarCurrentlySelectedScreenNotifications - case .reader: - return WPTabBarCurrentlySelectedScreenReader - default: - return "" + case .welcome: return "Welcome" + case .blog: return WPTabBarCurrentlySelectedScreenSites + case .notifications: return WPTabBarCurrentlySelectedScreenNotifications + case .reader: return WPTabBarCurrentlySelectedScreenReader + default: return "" } } } + // MARK: RootViewPresenter (Sites) + + var mySitesCoordinator: MySitesCoordinator + func currentlyVisibleBlog() -> Blog? { assert(Thread.isMainThread) return siteContent?.blog @@ -278,6 +275,11 @@ final class SplitViewRootPresenter: RootViewPresenter { } } + func showMySitesTab() { + guard let blog = currentlyVisibleBlog() else { return } + sidebarViewModel.selection = .blog(TaggedManagedObjectID(blog)) + } + // MARK: RootViewPresenter (Reader) func showReaderTab() { @@ -320,15 +322,7 @@ final class SplitViewRootPresenter: RootViewPresenter { fatalError() } - var mySitesCoordinator: MySitesCoordinator - - func showMySitesTab() { - guard let blog = currentlyVisibleBlog() else { - // Do nothing. - return - } - sidebarViewModel.selection = .blog(TaggedManagedObjectID(blog)) - } + // MARK: Notifications func showNotificationsTab(completion: ((NotificationsViewController) -> Void)?) { sidebarViewModel.selection = .notifications @@ -338,7 +332,7 @@ final class SplitViewRootPresenter: RootViewPresenter { } } - var meViewController: MeViewController? + // MARK: Me func showMeScreen(completion: ((MeViewController) -> Void)?) { if isDisplayingTabBar {