From 41260c971a4c45b7be4f8f53d5af545f2418bf3d Mon Sep 17 00:00:00 2001 From: Wind-Explorer Date: Thu, 15 Jan 2026 16:17:34 +0800 Subject: [PATCH] chore: cargo fmt --- src-tauri/src/commands/auth.rs | 2 +- src-tauri/src/commands/config.rs | 4 ++-- src-tauri/src/commands/dolls.rs | 4 ++-- src-tauri/src/commands/interaction.rs | 7 ++----- src-tauri/src/commands/sprite.rs | 2 +- src-tauri/src/services/cursor.rs | 8 ++++---- src-tauri/src/services/interaction.rs | 12 +++++------- src-tauri/src/services/ws.rs | 14 ++++++++++---- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src-tauri/src/commands/auth.rs b/src-tauri/src/commands/auth.rs index c0da5b0..04e702a 100644 --- a/src-tauri/src/commands/auth.rs +++ b/src-tauri/src/commands/auth.rs @@ -22,4 +22,4 @@ pub fn start_auth_flow() -> Result<(), String> { }); }) .map_err(|e| e.to_string()) -} \ No newline at end of file +} diff --git a/src-tauri/src/commands/config.rs b/src-tauri/src/commands/config.rs index a8f1b12..fe8c995 100644 --- a/src-tauri/src/commands/config.rs +++ b/src-tauri/src/commands/config.rs @@ -1,9 +1,9 @@ use crate::{ + lock_w, services::client_config_manager::{ load_app_config, open_config_manager_window, save_app_config, AppConfig, }, state::FDOLL, - lock_w, }; #[tauri::command] @@ -28,4 +28,4 @@ pub fn save_client_config(config: AppConfig) -> Result<(), String> { #[tauri::command] pub async fn open_client_config_manager() -> Result<(), String> { open_config_manager_window().map_err(|e| e.to_string()) -} \ No newline at end of file +} diff --git a/src-tauri/src/commands/dolls.rs b/src-tauri/src/commands/dolls.rs index aae1552..4a69cb4 100644 --- a/src-tauri/src/commands/dolls.rs +++ b/src-tauri/src/commands/dolls.rs @@ -1,10 +1,10 @@ use crate::{ + lock_r, remotes::{ dolls::{CreateDollDto, DollDto, DollsRemote, UpdateDollDto}, user::UserRemote, }, state::{init_app_data_scoped, AppDataRefreshScope, FDOLL}, - lock_r, }; use tauri::async_runtime; @@ -132,4 +132,4 @@ pub async fn remove_active_doll() -> Result<(), String> { }); Ok(()) -} \ No newline at end of file +} diff --git a/src-tauri/src/commands/interaction.rs b/src-tauri/src/commands/interaction.rs index 1529556..f9f60ac 100644 --- a/src-tauri/src/commands/interaction.rs +++ b/src-tauri/src/commands/interaction.rs @@ -1,9 +1,6 @@ -use crate::{ - models::interaction::SendInteractionDto, - services::interaction::send_interaction, -}; +use crate::{models::interaction::SendInteractionDto, services::interaction::send_interaction}; #[tauri::command] pub async fn send_interaction_cmd(dto: SendInteractionDto) -> Result<(), String> { send_interaction(dto).await -} \ No newline at end of file +} diff --git a/src-tauri/src/commands/sprite.rs b/src-tauri/src/commands/sprite.rs index 2c7847d..9da0698 100644 --- a/src-tauri/src/commands/sprite.rs +++ b/src-tauri/src/commands/sprite.rs @@ -12,4 +12,4 @@ pub fn recolor_gif_base64( apply_texture, ) .map_err(|e: Box| e.to_string()) -} \ No newline at end of file +} diff --git a/src-tauri/src/services/cursor.rs b/src-tauri/src/services/cursor.rs index 1f06239..c227642 100644 --- a/src-tauri/src/services/cursor.rs +++ b/src-tauri/src/services/cursor.rs @@ -71,7 +71,7 @@ pub async fn start_cursor_tracking() -> Result<(), String> { CURSOR_TRACKER.get_or_init(|| { // Initialize the shared state LATEST_CURSOR_POSITION.get_or_init(|| Arc::new(Mutex::new(None))); - + info!("First call to start_cursor_tracking - spawning cursor tracking task"); tauri::async_runtime::spawn(async { if let Err(e) = init_cursor_tracking().await { @@ -149,9 +149,9 @@ async fn init_cursor_tracking() -> Result<(), String> { // Update global state if let Some(mutex) = LATEST_CURSOR_POSITION.get() { - if let Ok(mut guard) = mutex.lock() { - *guard = Some(raw.clone()); - } + if let Ok(mut guard) = mutex.lock() { + *guard = Some(raw.clone()); + } } let mapped = absolute_to_normalized(&raw); diff --git a/src-tauri/src/services/interaction.rs b/src-tauri/src/services/interaction.rs index f871e3c..3b1ce95 100644 --- a/src-tauri/src/services/interaction.rs +++ b/src-tauri/src/services/interaction.rs @@ -2,10 +2,7 @@ use serde_json::json; use tracing::{error, info}; use crate::{ - lock_r, - models::interaction::SendInteractionDto, - services::ws::WS_EVENT, - state::FDOLL, + lock_r, models::interaction::SendInteractionDto, services::ws::WS_EVENT, state::FDOLL, }; pub async fn send_interaction(dto: SendInteractionDto) -> Result<(), String> { @@ -27,7 +24,7 @@ pub async fn send_interaction(dto: SendInteractionDto) -> Result<(), String> { // Prepare payload for client-send-interaction event // The DTO structure matches what the server expects: // { recipientUserId, content, type } (handled by serde rename_all="camelCase") - + // Note: The `type` field in DTO is mapped to `type_` in Rust struct but serialized as `type` // due to camelCase renaming (if we rely on TS-RS output) or manual renaming. // Wait, `type` is a reserved keyword in Rust so we used `type_`. @@ -36,7 +33,7 @@ pub async fn send_interaction(dto: SendInteractionDto) -> Result<(), String> { // It does NOT automatically handle `type_` -> `type`. // We should add `#[serde(rename = "type")]` to the `type_` field in the model. // I will fix the model first to ensure correct serialization. - + let payload = json!({ "recipientUserId": dto.recipient_user_id, "content": dto.content, @@ -49,7 +46,8 @@ pub async fn send_interaction(dto: SendInteractionDto) -> Result<(), String> { // but we are in an async context. Ideally we spawn_blocking. let spawn_result = tauri::async_runtime::spawn_blocking(move || { socket.emit(WS_EVENT::CLIENT_SEND_INTERACTION, payload) - }).await; + }) + .await; match spawn_result { Ok(emit_result) => match emit_result { diff --git a/src-tauri/src/services/ws.rs b/src-tauri/src/services/ws.rs index 0faea40..b6cc92a 100644 --- a/src-tauri/src/services/ws.rs +++ b/src-tauri/src/services/ws.rs @@ -373,13 +373,14 @@ fn on_interaction_received(payload: Payload, _socket: RawClient) { Payload::Text(values) => { if let Some(first_value) = values.first() { info!("Received interaction-received event: {:?}", first_value); - + let interaction_data: Result = serde_json::from_value(first_value.clone()); match interaction_data { Ok(data) => { - if let Err(e) = get_app_handle().emit(WS_EVENT::INTERACTION_RECEIVED, data) { + if let Err(e) = get_app_handle().emit(WS_EVENT::INTERACTION_RECEIVED, data) + { error!("Failed to emit interaction-received event: {:?}", e); } } @@ -399,14 +400,19 @@ fn on_interaction_delivery_failed(payload: Payload, _socket: RawClient) { match payload { Payload::Text(values) => { if let Some(first_value) = values.first() { - info!("Received interaction-delivery-failed event: {:?}", first_value); + info!( + "Received interaction-delivery-failed event: {:?}", + first_value + ); let failure_data: Result = serde_json::from_value(first_value.clone()); match failure_data { Ok(data) => { - if let Err(e) = get_app_handle().emit(WS_EVENT::INTERACTION_DELIVERY_FAILED, data) { + if let Err(e) = + get_app_handle().emit(WS_EVENT::INTERACTION_DELIVERY_FAILED, data) + { error!("Failed to emit interaction-delivery-failed event: {:?}", e); } }