From f39b7e998b4931f63add02c741fb7d5cc1f5c17c Mon Sep 17 00:00:00 2001 From: bobokun Date: Mon, 15 Sep 2025 21:33:20 -0400 Subject: [PATCH] refactor(desktop): improve mutex error handling in open_app_window Replace unwrap_or_else with explicit match for cleaner error handling when accessing MINIMIZE_TO_TRAY mutex. This provides better readability and follows Rust best practices for error handling. --- VERSION | 2 +- desktop/tauri/src-tauri/src/main.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 8d101ab..8bfd312 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.6.3-develop12 +4.6.3-develop13 diff --git a/desktop/tauri/src-tauri/src/main.rs b/desktop/tauri/src-tauri/src/main.rs index 2058d36..c26f52e 100644 --- a/desktop/tauri/src-tauri/src/main.rs +++ b/desktop/tauri/src-tauri/src/main.rs @@ -401,10 +401,13 @@ async fn wait_until_ready(port: u16, base_url: &Option, timeout: Duratio fn open_app_window(app: &AppHandle) { // Check if minimize to tray is enabled and respect it - let minimize_to_tray = *MINIMIZE_TO_TRAY.lock().unwrap_or_else(|_| { - // If lock fails, load setting directly - std::sync::Mutex::new(load_minimize_setting(app)) - }); + let minimize_to_tray = match MINIMIZE_TO_TRAY.lock() { + Ok(guard) => *guard, + Err(_) => { + // If lock fails, load setting directly + load_minimize_setting(app) + } + }; // Only show window if minimize to tray is disabled, or if explicitly requested if !minimize_to_tray {