diff --git a/src-tauri/src/api_server.rs b/src-tauri/src/api_server.rs index d93b6b5..cf3dd7a 100644 --- a/src-tauri/src/api_server.rs +++ b/src-tauri/src/api_server.rs @@ -410,7 +410,10 @@ async fn update_profile( // Update profile fields if let Some(new_name) = request.name { - if profile_manager.rename_profile(&state.app_handle, &name, &new_name).is_err() { + if profile_manager + .rename_profile(&state.app_handle, &name, &new_name) + .is_err() + { return Err(StatusCode::BAD_REQUEST); } } @@ -461,7 +464,10 @@ async fn update_profile( } if let Some(tags) = request.tags { - if profile_manager.update_profile_tags(&state.app_handle, &name, tags).is_err() { + if profile_manager + .update_profile_tags(&state.app_handle, &name, tags) + .is_err() + { return Err(StatusCode::BAD_REQUEST); } @@ -635,7 +641,11 @@ async fn create_proxy( // Convert JSON value to ProxySettings match serde_json::from_value(request.proxy_settings.clone()) { Ok(proxy_settings) => { - match PROXY_MANAGER.create_stored_proxy(&state.app_handle, request.name.clone(), proxy_settings) { + match PROXY_MANAGER.create_stored_proxy( + &state.app_handle, + request.name.clone(), + proxy_settings, + ) { Ok(_) => { // Find the created proxy to return it let proxies = PROXY_MANAGER.get_stored_proxies(); diff --git a/src-tauri/src/browser_runner.rs b/src-tauri/src/browser_runner.rs index 3545ffa..31995d5 100644 --- a/src-tauri/src/browser_runner.rs +++ b/src-tauri/src/browser_runner.rs @@ -909,7 +909,11 @@ impl BrowserRunner { }) } - pub fn delete_profile(&self, app_handle: tauri::AppHandle, profile_id: &str) -> Result<(), Box> { + pub fn delete_profile( + &self, + app_handle: tauri::AppHandle, + profile_id: &str, + ) -> Result<(), Box> { let profile_manager = ProfileManager::instance(); profile_manager.delete_profile(&app_handle, profile_id)?; @@ -2009,7 +2013,10 @@ pub fn rename_profile( } #[tauri::command] -pub async fn delete_profile(app_handle: tauri::AppHandle, profile_id: String) -> Result<(), String> { +pub async fn delete_profile( + app_handle: tauri::AppHandle, + profile_id: String, +) -> Result<(), String> { let browser_runner = BrowserRunner::instance(); browser_runner .delete_profile(app_handle, &profile_id) diff --git a/src-tauri/src/group_manager.rs b/src-tauri/src/group_manager.rs index 9b4b9f5..877ee21 100644 --- a/src-tauri/src/group_manager.rs +++ b/src-tauri/src/group_manager.rs @@ -257,7 +257,10 @@ pub async fn get_groups_with_profile_counts() -> Result, Str } #[tauri::command] -pub async fn create_profile_group(app_handle: tauri::AppHandle, name: String) -> Result { +pub async fn create_profile_group( + app_handle: tauri::AppHandle, + name: String, +) -> Result { let group_manager = GROUP_MANAGER.lock().unwrap(); group_manager .create_group(&app_handle, name) @@ -265,7 +268,11 @@ pub async fn create_profile_group(app_handle: tauri::AppHandle, name: String) -> } #[tauri::command] -pub async fn update_profile_group(app_handle: tauri::AppHandle, group_id: String, name: String) -> Result { +pub async fn update_profile_group( + app_handle: tauri::AppHandle, + group_id: String, + name: String, +) -> Result { let group_manager = GROUP_MANAGER.lock().unwrap(); group_manager .update_group(&app_handle, group_id, name) @@ -273,7 +280,10 @@ pub async fn update_profile_group(app_handle: tauri::AppHandle, group_id: String } #[tauri::command] -pub async fn delete_profile_group(app_handle: tauri::AppHandle, group_id: String) -> Result<(), String> { +pub async fn delete_profile_group( + app_handle: tauri::AppHandle, + group_id: String, +) -> Result<(), String> { let group_manager = GROUP_MANAGER.lock().unwrap(); group_manager .delete_group(&app_handle, group_id) diff --git a/src-tauri/src/profile/manager.rs b/src-tauri/src/profile/manager.rs index b73bf83..020a4f4 100644 --- a/src-tauri/src/profile/manager.rs +++ b/src-tauri/src/profile/manager.rs @@ -546,7 +546,9 @@ impl ProfileManager { })?; // Check if the browser is currently running using the comprehensive status check - let is_running = self.check_browser_status(app_handle.clone(), &profile).await?; + let is_running = self + .check_browser_status(app_handle.clone(), &profile) + .await?; if is_running { return Err( diff --git a/src-tauri/src/proxy_manager.rs b/src-tauri/src/proxy_manager.rs index 40857f2..0390cfb 100644 --- a/src-tauri/src/proxy_manager.rs +++ b/src-tauri/src/proxy_manager.rs @@ -5,8 +5,8 @@ use std::collections::HashMap; use std::fs; use std::path::PathBuf; use std::sync::Mutex; -use tauri_plugin_shell::ShellExt; use tauri::Emitter; +use tauri_plugin_shell::ShellExt; use crate::browser::ProxySettings; @@ -243,7 +243,11 @@ impl ProxyManager { } // Delete a stored proxy - pub fn delete_stored_proxy(&self, app_handle: &tauri::AppHandle, proxy_id: &str) -> Result<(), String> { + pub fn delete_stored_proxy( + &self, + app_handle: &tauri::AppHandle, + proxy_id: &str, + ) -> Result<(), String> { { let mut stored_proxies = self.stored_proxies.lock().unwrap(); if stored_proxies.remove(proxy_id).is_none() { diff --git a/src/app/page.tsx b/src/app/page.tsx index 91a25eb..52f32d3 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -62,11 +62,7 @@ export default function Home() { error: groupsError, } = useGroupEvents(); - const { - storedProxies, - isLoading: proxiesLoading, - error: proxiesError, - } = useProxyEvents(); + const { isLoading: proxiesLoading, error: proxiesError } = useProxyEvents(); const [createProfileDialogOpen, setCreateProfileDialogOpen] = useState(false); const [settingsDialogOpen, setSettingsDialogOpen] = useState(false); @@ -274,6 +270,20 @@ export default function Home() { } }, [profilesError]); + // Handle group errors from useGroupEvents hook + useEffect(() => { + if (groupsError) { + showErrorToast(groupsError); + } + }, [groupsError]); + + // Handle proxy errors from useProxyEvents hook + useEffect(() => { + if (proxiesError) { + showErrorToast(proxiesError); + } + }, [proxiesError]); + const checkAllPermissions = useCallback(async () => { try { // Wait for permissions to be initialized before checking diff --git a/src/components/proxy-management-dialog.tsx b/src/components/proxy-management-dialog.tsx index dc420aa..091d4d6 100644 --- a/src/components/proxy-management-dialog.tsx +++ b/src/components/proxy-management-dialog.tsx @@ -1,8 +1,8 @@ "use client"; import { invoke } from "@tauri-apps/api/core"; -import { emit, listen } from "@tauri-apps/api/event"; -import { useCallback, useEffect, useState } from "react"; +import { emit } from "@tauri-apps/api/event"; +import { useCallback, useState } from "react"; import { FiEdit2, FiPlus, FiTrash2, FiWifi } from "react-icons/fi"; import { toast } from "sonner"; import { DeleteConfirmationDialog } from "@/components/delete-confirmation-dialog";