mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Composer: Better autocomplete fix #146
This commit is contained in:
parent
7b25240f59
commit
5cb010b216
2 changed files with 4 additions and 1 deletions
|
@ -188,7 +188,7 @@ public class Client: ObservableObject, Equatable {
|
||||||
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
|
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
|
||||||
let httpBody = NSMutableData()
|
let httpBody = NSMutableData()
|
||||||
httpBody.append("--\(boundary)\r\n".data(using: .utf8)!)
|
httpBody.append("--\(boundary)\r\n".data(using: .utf8)!)
|
||||||
httpBody.append("Content-Disposition: form-data; name=\"\(filename)\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
|
httpBody.append("Content-Disposition: form-data; name=\"\(filename)\"; filename=\"\(filename)\"\r\n".data(using: .utf8)!)
|
||||||
httpBody.append("Content-Type: \(mimeType)\r\n".data(using: .utf8)!)
|
httpBody.append("Content-Type: \(mimeType)\r\n".data(using: .utf8)!)
|
||||||
httpBody.append("\r\n".data(using: .utf8)!)
|
httpBody.append("\r\n".data(using: .utf8)!)
|
||||||
httpBody.append(data)
|
httpBody.append(data)
|
||||||
|
|
|
@ -318,11 +318,13 @@ public class StatusEditorViewModel: ObservableObject {
|
||||||
|
|
||||||
private func loadAutoCompleteResults(query: String) {
|
private func loadAutoCompleteResults(query: String) {
|
||||||
guard let client, query.utf8.count > 1 else { return }
|
guard let client, query.utf8.count > 1 else { return }
|
||||||
|
var query = query
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
var results: SearchResults?
|
var results: SearchResults?
|
||||||
switch query.first {
|
switch query.first {
|
||||||
case "#":
|
case "#":
|
||||||
|
query.removeFirst()
|
||||||
results = try await client.get(endpoint: Search.search(query: query,
|
results = try await client.get(endpoint: Search.search(query: query,
|
||||||
type: "hashtags",
|
type: "hashtags",
|
||||||
offset: 0,
|
offset: 0,
|
||||||
|
@ -332,6 +334,7 @@ public class StatusEditorViewModel: ObservableObject {
|
||||||
tagsSuggestions = results?.hashtags ?? []
|
tagsSuggestions = results?.hashtags ?? []
|
||||||
}
|
}
|
||||||
case "@":
|
case "@":
|
||||||
|
query.removeFirst()
|
||||||
results = try await client.get(endpoint: Search.search(query: query,
|
results = try await client.get(endpoint: Search.search(query: query,
|
||||||
type: "accounts",
|
type: "accounts",
|
||||||
offset: 0,
|
offset: 0,
|
||||||
|
|
Loading…
Reference in a new issue