Allow searching for posts/users by opening URL with the tusker:// protocol

This commit is contained in:
Shadowfacts 2019-09-15 16:13:18 -04:00
parent df8e0dedd4
commit 078f9e076d
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 17 additions and 0 deletions

View File

@ -30,6 +30,23 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if url.host == "x-callback-url" {
return XCBManager.handle(url: url)
} else if var components = URLComponents(url: url, resolvingAgainstBaseURL: false),
let tabBarController = window!.rootViewController as? MainTabBarViewController,
let navigationController = tabBarController.viewControllers?[3] as? UINavigationController,
let searchController = navigationController.viewControllers.first as? SearchTableViewController {
components.scheme = "https"
tabBarController.selectedIndex = 3
navigationController.popToRootViewController(animated: false)
searchController.loadViewIfNeeded()
let query = components.url!.absoluteString
searchController.searchController.searchBar.searchTextField.text = query
searchController.performSearch(query: query)
return true
}
return false
}