Add X-Callback-URL for search
This commit is contained in:
parent
078f9e076d
commit
e17e00583f
|
@ -69,6 +69,8 @@ Dates in responses are encoded as Unix timestamps.
|
|||
- [`dismissAllNotifications`](#dismissallnotifications)
|
||||
- [Instances](#instances)
|
||||
- [`getCurrentInstance`](#getcurrentinstance)
|
||||
- [Misc](#misc)
|
||||
- [`search`](#search)
|
||||
|
||||
### Accounts
|
||||
|
||||
|
@ -336,3 +338,18 @@ No parameters.
|
|||
| `description` (string) | The instance description | No |
|
||||
| `contactAccount` (string) | The instance-local ID of the instance's contact account | No |
|
||||
|
||||
|
||||
### Misc
|
||||
|
||||
#### `search`
|
||||
Performs a search in Tusker with the given query
|
||||
|
||||
##### Request
|
||||
|
||||
| Parameter (type) | Description | Optional |
|
||||
| ---------------- | ------------------------ |--------- |
|
||||
| `query` (string) | The search query to use. | No |
|
||||
|
||||
##### Response
|
||||
|
||||
No data if successful.
|
|
@ -43,7 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
searchController.loadViewIfNeeded()
|
||||
|
||||
let query = components.url!.absoluteString
|
||||
searchController.searchController.searchBar.searchTextField.text = query
|
||||
searchController.searchController.searchBar.text = query
|
||||
searchController.performSearch(query: query)
|
||||
|
||||
return true
|
||||
|
|
|
@ -20,6 +20,8 @@ enum XCBActionType: String {
|
|||
case getAccount
|
||||
case getCurrentUser
|
||||
case followUser
|
||||
// Search
|
||||
case search
|
||||
|
||||
var path: String {
|
||||
return "/\(rawValue)"
|
||||
|
|
|
@ -314,4 +314,21 @@ struct XCBActions {
|
|||
|
||||
getAccount(from: request, session: session, completion: follow)
|
||||
}
|
||||
|
||||
// MARK: - Search
|
||||
|
||||
static func search(_ request: XCBRequest, _ session: XCBSession, _ silent: Bool?) {
|
||||
let query = request.arguments["query"]!
|
||||
|
||||
if let tabBarController = UIApplication.shared.keyWindow?.rootViewController as? UITabBarController,
|
||||
let navigationController = tabBarController.viewControllers?[3] as? UINavigationController,
|
||||
let searchController = navigationController.viewControllers.first as? SearchTableViewController {
|
||||
tabBarController.selectedIndex = 3
|
||||
navigationController.popToRootViewController(animated: false)
|
||||
searchController.searchController.searchBar.text = query
|
||||
searchController.performSearch(query: query)
|
||||
} else {
|
||||
session.complete(with: .error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@ class XCBManager {
|
|||
XCBRequestSpec(type: .showAccount, arguments: ["accountID": true, "accountURL": true, "acct": true], canRunSilently: false, action: XCBActions.showAccount),
|
||||
XCBRequestSpec(type: .getAccount, arguments: ["accountID": true, "accountURL": true, "acct": true], canRunSilently: false, action: XCBActions.getAccount),
|
||||
XCBRequestSpec(type: .getCurrentUser, arguments: [:], canRunSilently: false, action: XCBActions.getCurrentUser),
|
||||
XCBRequestSpec(type: .followUser, arguments: ["accountID": true, "accountURL": true, "acct": true], canRunSilently: true, action: XCBActions.followUser)
|
||||
XCBRequestSpec(type: .followUser, arguments: ["accountID": true, "accountURL": true, "acct": true], canRunSilently: true, action: XCBActions.followUser),
|
||||
// Search
|
||||
XCBRequestSpec(type: .search, arguments: ["query": false], canRunSilently: false, action: XCBActions.search),
|
||||
]
|
||||
|
||||
static var currentSession: XCBSession?
|
||||
|
|
Loading…
Reference in New Issue