fix: pass id instead of profile name to open_url_with_profile

This commit is contained in:
zhom
2025-08-19 13:38:29 +04:00
parent e12a5661b1
commit f5066e866b
2 changed files with 12 additions and 12 deletions
+8 -8
View File
@@ -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
}
+4 -4
View File
@@ -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();