forked from shadowfacts/Tusker
Workaround for tab bar content VC not being in responder chain almost ever
Closes #544, #179
This commit is contained in:
parent
20692b0630
commit
242c60d74d
|
@ -484,3 +484,11 @@ extension ConversationViewController: StatusBarTappableViewController {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ConversationViewController: RefreshableViewController {
|
||||
func refresh() {
|
||||
Task {
|
||||
await refreshContext()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,6 +151,22 @@ class BaseMainTabBarViewController: UITabBarController, FastAccountSwitcherViewC
|
|||
return false
|
||||
#endif // !os(visionOS)
|
||||
}
|
||||
|
||||
// MARK: Keyboard shortcuts
|
||||
|
||||
override func target(forAction action: Selector, withSender sender: Any?) -> Any? {
|
||||
// This is a silly workaround for when the sidebar is focused (and therefore first responder), which,
|
||||
// unfortunately, is almost always. Because the content view controller then isn't in the responder chain,
|
||||
// we manually delegate to the top view controller if possible.
|
||||
if action == #selector(RefreshableViewController.refresh),
|
||||
let selected = selectedViewController as? NavigationControllerProtocol,
|
||||
let top = selected.topViewController as? RefreshableViewController {
|
||||
return top
|
||||
} else {
|
||||
return super.target(forAction: action, withSender: sender)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension BaseMainTabBarViewController: TuskerNavigationDelegate {
|
||||
|
|
|
@ -219,6 +219,19 @@ class MainSplitViewController: UISplitViewController {
|
|||
@objc func handleComposeKeyCommand() {
|
||||
compose(editing: nil)
|
||||
}
|
||||
|
||||
override func target(forAction action: Selector, withSender sender: Any?) -> Any? {
|
||||
// This is a silly workaround for when the sidebar is focused (and therefore first responder), which,
|
||||
// unfortunately, is almost always. Because the content view controller then isn't in the responder chain,
|
||||
// we manually delegate to the top view controller if possible.
|
||||
if action == #selector(RefreshableViewController.refresh),
|
||||
traitCollection.horizontalSizeClass == .regular,
|
||||
let top = secondaryNavController.topViewController as? RefreshableViewController {
|
||||
return top
|
||||
} else {
|
||||
return super.target(forAction: action, withSender: sender)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -180,3 +180,9 @@ extension NotificationsPageViewController: StateRestorableViewController {
|
|||
return currentPage.userActivity(accountID: mastodonController.accountInfo!.id)
|
||||
}
|
||||
}
|
||||
|
||||
extension NotificationsPageViewController: RefreshableViewController {
|
||||
func refresh() {
|
||||
(currentViewController as? RefreshableViewController)?.refresh()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -393,3 +393,9 @@ extension ProfileViewController: StatusBarTappableViewController {
|
|||
return currentViewController.handleStatusBarTapped(xPosition: xPosition)
|
||||
}
|
||||
}
|
||||
|
||||
extension ProfileViewController: RefreshableViewController {
|
||||
func refresh() {
|
||||
currentViewController.refresh()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -212,3 +212,9 @@ extension TimelinesPageViewController: StateRestorableViewController {
|
|||
return (currentViewController as? TimelineViewController)?.stateRestorationActivity()
|
||||
}
|
||||
}
|
||||
|
||||
extension TimelinesPageViewController: RefreshableViewController {
|
||||
func refresh() {
|
||||
(currentViewController as? RefreshableViewController)?.refresh()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue