mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 10:11:00 +00:00
Use V1 accounts API for autocomplete
This commit is contained in:
parent
330aa93437
commit
df1a44cc21
2 changed files with 11 additions and 7 deletions
|
@ -2,17 +2,21 @@ import Foundation
|
|||
|
||||
public enum Search: Endpoint {
|
||||
case search(query: String, type: String?, offset: Int?, following: Bool?)
|
||||
case accountsSearch(query: String, type: String?, offset: Int?, following: Bool?)
|
||||
|
||||
public func path() -> String {
|
||||
switch self {
|
||||
case .search:
|
||||
"search"
|
||||
case .accountsSearch:
|
||||
"accounts/search"
|
||||
}
|
||||
}
|
||||
|
||||
public func queryItems() -> [URLQueryItem]? {
|
||||
switch self {
|
||||
case let .search(query, type, offset, following):
|
||||
case let .search(query, type, offset, following),
|
||||
let .accountsSearch(query, type, offset, following):
|
||||
var params: [URLQueryItem] = [.init(name: "q", value: query)]
|
||||
if let type {
|
||||
params.append(.init(name: "type", value: type))
|
||||
|
|
|
@ -482,16 +482,16 @@ import SwiftUI
|
|||
}
|
||||
case "@":
|
||||
query.removeFirst()
|
||||
results = try await client.get(endpoint: Search.search(query: query,
|
||||
type: "accounts",
|
||||
offset: 0,
|
||||
following: true),
|
||||
forceVersion: .v2)
|
||||
let accounts: [Account] = try await client.get(endpoint: Search.accountsSearch(query: query,
|
||||
type: nil,
|
||||
offset: 0,
|
||||
following: nil),
|
||||
forceVersion: .v1)
|
||||
guard !Task.isCancelled else {
|
||||
return
|
||||
}
|
||||
withAnimation {
|
||||
mentionsSuggestions = results?.accounts ?? []
|
||||
mentionsSuggestions = accounts
|
||||
}
|
||||
default:
|
||||
break
|
||||
|
|
Loading…
Reference in a new issue