Add X-Callback-URL for search

This commit is contained in:
Shadowfacts 2019-09-15 18:12:49 -04:00
rodič 078f9e076d
revize e17e00583f
Podepsáno: shadowfacts
ID GPG klíče: 94A5AB95422746E5
5 změnil soubory, kde provedl 40 přidání a 2 odebrání

Zobrazit soubor

@ -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.

Zobrazit soubor

@ -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

Zobrazit soubor

@ -20,6 +20,8 @@ enum XCBActionType: String {
case getAccount
case getCurrentUser
case followUser
// Search
case search
var path: String {
return "/\(rawValue)"

Zobrazit soubor

@ -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)
}
}
}

Zobrazit soubor

@ -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?