mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-04-26 05:46:23 +02:00
fix: pass id instead of profile name to open_url_with_profile
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user