Archived
feat: refine native iOS chat experience
This commit is contained in:
1 parent
9c5e9bce5b
commit
7bd893ae5c
14 files changed
+415
-93
No files matched your search
@@ -208,14 +208,24 @@ final class ChatStore: ObservableObject {
|
||||
else if regenerate { draft = target.content; await send() }
|
||||
} catch { busy = false; await failure(error) }
|
||||
}
|
||||
func saveWorkspace(_ workspace: HopeWorkspace?, name: String, instructions: String) async {
|
||||
guard !name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { return }
|
||||
@discardableResult
|
||||
func saveWorkspace(_ workspace: HopeWorkspace?, name: String, instructions: String) async -> Bool {
|
||||
guard !name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
||||
error = "Enter a workspace name."
|
||||
return false
|
||||
}
|
||||
do {
|
||||
var body: [String: Any] = ["name": name, "instructions": instructions]
|
||||
if let workspace { body["revision"] = workspace.revision }
|
||||
let _: WorkspaceEnvelope = try await call(workspace.map { "api/workspaces/\($0.id)" } ?? "api/workspaces", method: workspace == nil ? "POST" : "PATCH", body: body)
|
||||
let result: WorkspacePage = try await call("api/workspaces"); workspaces = result.workspaces
|
||||
} catch { await failure(error) }
|
||||
let result: WorkspacePage = try await call("api/workspaces")
|
||||
workspaces = result.workspaces
|
||||
error = nil
|
||||
return true
|
||||
} catch {
|
||||
await failure(error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
func deleteWorkspace(_ workspace: HopeWorkspace) async {
|
||||
do {
|
||||
|
||||
Reference in new issue
Block a user