From f5066e866b2b4336479b095f675606d7cb208be4 Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Tue, 19 Aug 2025 13:38:29 +0400 Subject: [PATCH] fix: pass id instead of profile name to open_url_with_profile --- src-tauri/src/default_browser.rs | 16 ++++++++-------- src/components/profile-selector-dialog.tsx | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src-tauri/src/default_browser.rs b/src-tauri/src/default_browser.rs index ff54187..1f6d9a2 100644 --- a/src-tauri/src/default_browser.rs +++ b/src-tauri/src/default_browser.rs @@ -42,7 +42,7 @@ impl DefaultBrowser { pub async fn open_url_with_profile( &self, app_handle: tauri::AppHandle, - profile_name: String, + profile_id: String, url: String, ) -> Result<(), String> { let runner = crate::browser_runner::BrowserRunner::instance(); @@ -53,21 +53,21 @@ impl DefaultBrowser { .map_err(|e| format!("Failed to list profiles: {e}"))?; let profile = profiles .into_iter() - .find(|p| p.name == profile_name) - .ok_or_else(|| format!("Profile '{profile_name}' not found"))?; + .find(|p| p.id.to_string() == profile_id) + .ok_or_else(|| format!("Profile '{profile_id}' not found"))?; - println!("Opening URL '{url}' with profile '{profile_name}'"); + println!("Opening URL '{url}' with profile '{profile_id}'"); // Use launch_or_open_url which handles both launching new instances and opening in existing ones runner .launch_or_open_url(app_handle, &profile, Some(url.clone()), None) .await .map_err(|e| { - println!("Failed to open URL with profile '{profile_name}': {e}"); + println!("Failed to open URL with profile '{profile_id}': {e}"); format!("Failed to open URL with profile: {e}") })?; - println!("Successfully opened URL '{url}' with profile '{profile_name}'"); + println!("Successfully opened URL '{url}' with profile '{profile_id}'"); Ok(()) } } @@ -574,11 +574,11 @@ pub async fn set_as_default_browser() -> Result<(), String> { #[tauri::command] pub async fn open_url_with_profile( app_handle: tauri::AppHandle, - profile_name: String, + profile_id: String, url: String, ) -> Result<(), String> { let default_browser = DefaultBrowser::instance(); default_browser - .open_url_with_profile(app_handle, profile_name, url) + .open_url_with_profile(app_handle, profile_id, url) .await } diff --git a/src/components/profile-selector-dialog.tsx b/src/components/profile-selector-dialog.tsx index b5c2012..fd7781a 100644 --- a/src/components/profile-selector-dialog.tsx +++ b/src/components/profile-selector-dialog.tsx @@ -94,12 +94,12 @@ export function ProfileSelectorDialog({ setIsLaunching(true); const selected = profiles.find((p) => p.name === selectedProfile); - if (selected) { - setLaunchingProfiles((prev) => new Set(prev).add(selected.id)); - } + if (!selected) return; + + setLaunchingProfiles((prev) => new Set(prev).add(selected.id)); try { await invoke("open_url_with_profile", { - profileId: selectedProfile, + profileId: selected.id, url, }); onClose();