Skip to content

Commit e1000fe

Browse files
committed
review
1 parent e425548 commit e1000fe

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

Coder-Desktop/Coder-Desktop/Views/FileSync/FilePicker.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ class FilePickerModel: ObservableObject {
7878
@Published var isLoading: Bool = false
7979
@Published var error: ClientError?
8080

81-
let client: Client
81+
let client: AgentClient
8282

8383
init(host: String) {
84-
client = Client(url: URL(string: "http://\(host):4")!)
84+
client = AgentClient(agentHost: host)
8585
}
8686

8787
func loadRoot() {
@@ -176,7 +176,7 @@ class FilePickerItemModel: Identifiable, ObservableObject {
176176
// This being a binding is pretty important performance-wise, as it's a struct
177177
// that would otherwise be recreated every time the the item row is rendered.
178178
// Removing the binding results in very noticeable lag when scrolling a file tree.
179-
@Binding var client: Client
179+
@Binding var client: AgentClient
180180

181181
@Published var contents: [FilePickerItemModel]?
182182
@Published var isLoading = false
@@ -197,7 +197,7 @@ class FilePickerItemModel: Identifiable, ObservableObject {
197197

198198
init(
199199
name: String,
200-
client: Binding<Client>,
200+
client: Binding<AgentClient>,
201201
absolute_path: String,
202202
path: [String],
203203
dir: Bool = false,
@@ -237,7 +237,7 @@ class FilePickerItemModel: Identifiable, ObservableObject {
237237

238238
extension LSResponse {
239239
@MainActor
240-
func toModels(client: Binding<Client>, path: [String]) -> [FilePickerItemModel] {
240+
func toModels(client: Binding<AgentClient>, path: [String]) -> [FilePickerItemModel] {
241241
contents.compactMap { file in
242242
// Filter dotfiles from the picker
243243
guard !file.name.hasPrefix(".") else { return nil }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public struct AgentClient: Sendable {
2+
let client: Client
3+
4+
public init(agentHost: String) {
5+
client = Client(url: URL(string: "http://\(agentHost):4")!)
6+
}
7+
}

Coder-Desktop/CoderSDK/AgentLS.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
public extension Client {
2-
// The Client's URL MUST be set to that of an accessible agent
1+
public extension AgentClient {
32
func listAgentDirectory(_ req: LSRequest) async throws(ClientError) -> LSResponse {
4-
let res = try await request("/api/v0/list-directory", method: .post, body: req)
3+
let res = try await client.request("/api/v0/list-directory", method: .post, body: req)
54
guard res.resp.statusCode == 200 else {
6-
throw responseAsError(res)
5+
throw client.responseAsError(res)
76
}
8-
return try decode(LSResponse.self, from: res.data)
7+
return try client.decode(LSResponse.self, from: res.data)
98
}
109
}
1110

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy