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.
This commit is contained in:
bobokun 2025-09-15 21:33:20 -04:00
parent d24d2e0954
commit f39b7e998b
No known key found for this signature in database
GPG key ID: B73932169607D927
2 changed files with 8 additions and 5 deletions

View file

@ -1 +1 @@
4.6.3-develop12
4.6.3-develop13

View file

@ -401,10 +401,13 @@ async fn wait_until_ready(port: u16, base_url: &Option<String>, 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 {