From cdd9ec36229bfa68043f52dd3864a3a3264100e0 Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Wed, 30 Apr 2025 10:50:07 +0200 Subject: [PATCH] fix double opening window --- .../src-tauri/src/operations/app/link.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/nym-wallet/src-tauri/src/operations/app/link.rs b/nym-wallet/src-tauri/src/operations/app/link.rs index fa41aa8f19..ef309a0030 100644 --- a/nym-wallet/src-tauri/src/operations/app/link.rs +++ b/nym-wallet/src-tauri/src/operations/app/link.rs @@ -4,8 +4,21 @@ use tauri_plugin_opener::OpenerExt; pub async fn open_url(url: String, app_handle: tauri::AppHandle) -> Result<(), String> { println!("Opening URL: {}", url); - match app_handle.opener().open_url(&url, None::<&str>) { - Ok(_) => Ok(()), - Err(err) => Err(format!("Failed to open URL: {}", err)), + #[cfg(target_os = "windows")] + { + // Windows needs shell capability + match app_handle.shell().open("", &url) { + Ok(_) => Ok(()), + Err(err) => Err(format!("Failed to open URL: {}", err)), + } + } + + #[cfg(not(target_os = "windows"))] + { + // macOS and Linux work well with opener + match app_handle.opener().open_url(&url, None::<&str>) { + Ok(_) => Ok(()), + Err(err) => Err(format!("Failed to open URL: {}", err)), + } } }