chore: cargo fmt

This commit is contained in:
2026-01-15 16:17:34 +08:00
parent 86d964943e
commit 41260c971a
8 changed files with 27 additions and 26 deletions

View File

@@ -22,4 +22,4 @@ pub fn start_auth_flow() -> Result<(), String> {
}); });
}) })
.map_err(|e| e.to_string()) .map_err(|e| e.to_string())
} }

View File

@@ -1,9 +1,9 @@
use crate::{ use crate::{
lock_w,
services::client_config_manager::{ services::client_config_manager::{
load_app_config, open_config_manager_window, save_app_config, AppConfig, load_app_config, open_config_manager_window, save_app_config, AppConfig,
}, },
state::FDOLL, state::FDOLL,
lock_w,
}; };
#[tauri::command] #[tauri::command]
@@ -28,4 +28,4 @@ pub fn save_client_config(config: AppConfig) -> Result<(), String> {
#[tauri::command] #[tauri::command]
pub async fn open_client_config_manager() -> Result<(), String> { pub async fn open_client_config_manager() -> Result<(), String> {
open_config_manager_window().map_err(|e| e.to_string()) open_config_manager_window().map_err(|e| e.to_string())
} }

View File

@@ -1,10 +1,10 @@
use crate::{ use crate::{
lock_r,
remotes::{ remotes::{
dolls::{CreateDollDto, DollDto, DollsRemote, UpdateDollDto}, dolls::{CreateDollDto, DollDto, DollsRemote, UpdateDollDto},
user::UserRemote, user::UserRemote,
}, },
state::{init_app_data_scoped, AppDataRefreshScope, FDOLL}, state::{init_app_data_scoped, AppDataRefreshScope, FDOLL},
lock_r,
}; };
use tauri::async_runtime; use tauri::async_runtime;
@@ -132,4 +132,4 @@ pub async fn remove_active_doll() -> Result<(), String> {
}); });
Ok(()) Ok(())
} }

View File

@@ -1,9 +1,6 @@
use crate::{ use crate::{models::interaction::SendInteractionDto, services::interaction::send_interaction};
models::interaction::SendInteractionDto,
services::interaction::send_interaction,
};
#[tauri::command] #[tauri::command]
pub async fn send_interaction_cmd(dto: SendInteractionDto) -> Result<(), String> { pub async fn send_interaction_cmd(dto: SendInteractionDto) -> Result<(), String> {
send_interaction(dto).await send_interaction(dto).await
} }

View File

@@ -12,4 +12,4 @@ pub fn recolor_gif_base64(
apply_texture, apply_texture,
) )
.map_err(|e: Box<dyn std::error::Error>| e.to_string()) .map_err(|e: Box<dyn std::error::Error>| e.to_string())
} }

View File

@@ -71,7 +71,7 @@ pub async fn start_cursor_tracking() -> Result<(), String> {
CURSOR_TRACKER.get_or_init(|| { CURSOR_TRACKER.get_or_init(|| {
// Initialize the shared state // Initialize the shared state
LATEST_CURSOR_POSITION.get_or_init(|| Arc::new(Mutex::new(None))); LATEST_CURSOR_POSITION.get_or_init(|| Arc::new(Mutex::new(None)));
info!("First call to start_cursor_tracking - spawning cursor tracking task"); info!("First call to start_cursor_tracking - spawning cursor tracking task");
tauri::async_runtime::spawn(async { tauri::async_runtime::spawn(async {
if let Err(e) = init_cursor_tracking().await { if let Err(e) = init_cursor_tracking().await {
@@ -149,9 +149,9 @@ async fn init_cursor_tracking() -> Result<(), String> {
// Update global state // Update global state
if let Some(mutex) = LATEST_CURSOR_POSITION.get() { if let Some(mutex) = LATEST_CURSOR_POSITION.get() {
if let Ok(mut guard) = mutex.lock() { if let Ok(mut guard) = mutex.lock() {
*guard = Some(raw.clone()); *guard = Some(raw.clone());
} }
} }
let mapped = absolute_to_normalized(&raw); let mapped = absolute_to_normalized(&raw);

View File

@@ -2,10 +2,7 @@ use serde_json::json;
use tracing::{error, info}; use tracing::{error, info};
use crate::{ use crate::{
lock_r, lock_r, models::interaction::SendInteractionDto, services::ws::WS_EVENT, state::FDOLL,
models::interaction::SendInteractionDto,
services::ws::WS_EVENT,
state::FDOLL,
}; };
pub async fn send_interaction(dto: SendInteractionDto) -> Result<(), String> { 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 // Prepare payload for client-send-interaction event
// The DTO structure matches what the server expects: // The DTO structure matches what the server expects:
// { recipientUserId, content, type } (handled by serde rename_all="camelCase") // { 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` // 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. // 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_`. // 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`. // It does NOT automatically handle `type_` -> `type`.
// We should add `#[serde(rename = "type")]` to the `type_` field in the model. // We should add `#[serde(rename = "type")]` to the `type_` field in the model.
// I will fix the model first to ensure correct serialization. // I will fix the model first to ensure correct serialization.
let payload = json!({ let payload = json!({
"recipientUserId": dto.recipient_user_id, "recipientUserId": dto.recipient_user_id,
"content": dto.content, "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. // but we are in an async context. Ideally we spawn_blocking.
let spawn_result = tauri::async_runtime::spawn_blocking(move || { let spawn_result = tauri::async_runtime::spawn_blocking(move || {
socket.emit(WS_EVENT::CLIENT_SEND_INTERACTION, payload) socket.emit(WS_EVENT::CLIENT_SEND_INTERACTION, payload)
}).await; })
.await;
match spawn_result { match spawn_result {
Ok(emit_result) => match emit_result { Ok(emit_result) => match emit_result {

View File

@@ -373,13 +373,14 @@ fn on_interaction_received(payload: Payload, _socket: RawClient) {
Payload::Text(values) => { Payload::Text(values) => {
if let Some(first_value) = values.first() { if let Some(first_value) = values.first() {
info!("Received interaction-received event: {:?}", first_value); info!("Received interaction-received event: {:?}", first_value);
let interaction_data: Result<InteractionPayloadDto, _> = let interaction_data: Result<InteractionPayloadDto, _> =
serde_json::from_value(first_value.clone()); serde_json::from_value(first_value.clone());
match interaction_data { match interaction_data {
Ok(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); error!("Failed to emit interaction-received event: {:?}", e);
} }
} }
@@ -399,14 +400,19 @@ fn on_interaction_delivery_failed(payload: Payload, _socket: RawClient) {
match payload { match payload {
Payload::Text(values) => { Payload::Text(values) => {
if let Some(first_value) = values.first() { 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<InteractionDeliveryFailedDto, _> = let failure_data: Result<InteractionDeliveryFailedDto, _> =
serde_json::from_value(first_value.clone()); serde_json::from_value(first_value.clone());
match failure_data { match failure_data {
Ok(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); error!("Failed to emit interaction-delivery-failed event: {:?}", e);
} }
} }