From 83c7609df55a0b5a33726c0055c5d8b87a32a94c Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 21 Sep 2020 18:09:23 -0400 Subject: [PATCH] Fix crash when using app icon shortcuts --- Tusker/Screens/Main/MainSplitViewController.swift | 11 ++++++++--- Tusker/Shortcuts/AppShortcutItems.swift | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Tusker/Screens/Main/MainSplitViewController.swift b/Tusker/Screens/Main/MainSplitViewController.swift index c11b65d45f..3bdd94e13d 100644 --- a/Tusker/Screens/Main/MainSplitViewController.swift +++ b/Tusker/Screens/Main/MainSplitViewController.swift @@ -315,10 +315,15 @@ extension MainSplitViewController: TuskerRootViewController { } func select(tab: MainTabBarViewController.Tab) { - if tab == .compose { - presentCompose() + if traitCollection.horizontalSizeClass == .compact { + tabBarViewController?.select(tab: tab) } else { - select(item: .tab(tab)) + if tab == .compose { + presentCompose() + } else { + select(item: .tab(tab)) + sidebar.select(item: .tab(tab), animated: false) + } } } } diff --git a/Tusker/Shortcuts/AppShortcutItems.swift b/Tusker/Shortcuts/AppShortcutItems.swift index d0efdffa8f..334c02ebdd 100644 --- a/Tusker/Shortcuts/AppShortcutItems.swift +++ b/Tusker/Shortcuts/AppShortcutItems.swift @@ -47,8 +47,9 @@ enum AppShortcutItem: String, CaseIterable { } let scene = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.first! let window = scene.windows.first { $0.isKeyWindow }! - let controller = window.rootViewController as! MainTabBarViewController - controller.select(tab: tab) + if let controller = window.rootViewController as? TuskerRootViewController { + controller.select(tab: tab) + } } }