From 056ff0567786aa2c0c061d9e5f8b401a079bc46a Mon Sep 17 00:00:00 2001 From: quexeky Date: Tue, 11 Mar 2025 19:26:05 +1100 Subject: [PATCH] chore(collections): Slightly fixed return value for collections Signed-off-by: quexeky --- .../src/games/collections/commands.rs | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/desktop/src-tauri/src/games/collections/commands.rs b/desktop/src-tauri/src/games/collections/commands.rs index dbef3442..0a72ad92 100644 --- a/desktop/src-tauri/src/games/collections/commands.rs +++ b/desktop/src-tauri/src/games/collections/commands.rs @@ -28,26 +28,32 @@ pub fn fetch_collection(id: String) -> Result { } #[tauri::command] -pub fn create_collection(name: String) -> Result { +pub fn create_collection(name: String) -> Result<(), RemoteAccessError> { let client = Client::new(); let base_url = DB.fetch_base_url(); - let base_url = Url::parse(&format!("{}/api/v1/client/collection/", base_url))?; + let base_url = Url::parse(&format!("{}api/v1/client/collection/", base_url))?; let response = client .post(base_url) .header("Authorization", generate_authorization_header()) - .json(&{name}) - .send()?; - Ok(response.json()?) + .json(&{name}); + + println!("{:?}", response); + + + println!("{}", response.send()?.text().unwrap()); + + + Ok(()) } #[tauri::command] pub fn add_game_to_collection(name: String) -> Result<(), RemoteAccessError> { let client = Client::new(); - let url = Url::parse(&format!("{}/api/v1/client/collection/{}/entry/", DB.fetch_base_url(), name))?; + let url = Url::parse(&format!("{}api/v1/client/collection/{}/entry/", DB.fetch_base_url(), name))?; - client + let response = client .post(url) .header("Authorization", generate_authorization_header()) .send()?; @@ -57,7 +63,7 @@ pub fn add_game_to_collection(name: String) -> Result<(), RemoteAccessError> { #[tauri::command] pub fn delete_collection(id: String) -> Result { let client = Client::new(); - let base_url = Url::parse(&format!("{}/api/v1/client/collection/{}", DB.fetch_base_url(), id))?; + let base_url = Url::parse(&format!("{}api/v1/client/collection/{}", DB.fetch_base_url(), id))?; let response = client .delete(base_url) @@ -69,7 +75,7 @@ pub fn delete_collection(id: String) -> Result { #[tauri::command] pub fn delete_game_in_collection(id: String) -> Result<(), RemoteAccessError> { let client = Client::new(); - let base_url = Url::parse(&format!("{}/api/v1/client/collection/{}/entry", DB.fetch_base_url(), id))?; + let base_url = Url::parse(&format!("{}api/v1/client/collection/{}/entry", DB.fetch_base_url(), id))?; client .delete(base_url)