feat: add workspace and conversation Tauri commands
Implement list_workspaces and list_conversations commands to enable frontend access to workspace and conversation data via Tauri IPC. - Add workspace.rs with list_workspaces command (GET /workspaces) - Add conversation.rs with list_conversations command (GET /conversations?workspace_id=) - Register both commands in lib.rs invoke_handler - Update commands/mod.rs to expose new modules
This commit is contained in:
18
src-tauri/src/commands/conversation.rs
Normal file
18
src-tauri/src/commands/conversation.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
use crate::models::Conversation;
|
||||
use crate::state::{AppState, BASE_URL};
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn list_conversations(
|
||||
state: tauri::State<'_, AppState>,
|
||||
workspace_id: String,
|
||||
) -> Result<Vec<Conversation>, String> {
|
||||
state
|
||||
.client
|
||||
.get(format!("{}/conversations?workspace_id={}", BASE_URL, workspace_id))
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| e.to_string())?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
pub mod conversation;
|
||||
pub mod user;
|
||||
pub mod workspace;
|
||||
|
||||
15
src-tauri/src/commands/workspace.rs
Normal file
15
src-tauri/src/commands/workspace.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use crate::models::Workspace;
|
||||
use crate::state::{AppState, BASE_URL};
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn list_workspaces(state: tauri::State<'_, AppState>) -> Result<Vec<Workspace>, String> {
|
||||
state
|
||||
.client
|
||||
.get(format!("{}/workspaces", BASE_URL))
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| e.to_string())?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
Reference in New Issue
Block a user