diff --git a/src/ui/Desktop/Apps/Credentials/CredentialViewer.tsx b/src/ui/Desktop/Apps/Credentials/CredentialViewer.tsx index 8edf5279..65be063c 100644 --- a/src/ui/Desktop/Apps/Credentials/CredentialViewer.tsx +++ b/src/ui/Desktop/Apps/Credentials/CredentialViewer.tsx @@ -70,7 +70,7 @@ const CredentialViewer: React.FC = ({ try { const response = await getCredentialDetails(credential.id); setCredentialDetails(response); - } catch (error) { + } catch { toast.error(t("credentials.failedToFetchCredentialDetails")); } }; @@ -79,7 +79,7 @@ const CredentialViewer: React.FC = ({ try { const response = await getCredentialHosts(credential.id); setHostsUsing(response); - } catch (error) { + } catch { toast.error(t("credentials.failedToFetchHostsUsing")); } finally { setLoading(false); @@ -97,7 +97,7 @@ const CredentialViewer: React.FC = ({ try { await navigator.clipboard.writeText(text); toast.success(t("copiedToClipboard", { field: fieldName })); - } catch (error) { + } catch { toast.error(t("credentials.failedToCopy")); } }; diff --git a/src/ui/Desktop/Apps/Host Manager/HostManagerEditor.tsx b/src/ui/Desktop/Apps/Host Manager/HostManagerEditor.tsx index bf89992f..5f4c0224 100644 --- a/src/ui/Desktop/Apps/Host Manager/HostManagerEditor.tsx +++ b/src/ui/Desktop/Apps/Host Manager/HostManagerEditor.tsx @@ -38,7 +38,7 @@ import { CredentialSelector } from "@/ui/Desktop/Apps/Credentials/CredentialSele import CodeMirror from "@uiw/react-codemirror"; import { oneDark } from "@codemirror/theme-one-dark"; import { EditorView } from "@codemirror/view"; -import type { StatsConfig, WidgetType } from "@/types/stats-widgets"; +import type { StatsConfig } from "@/types/stats-widgets"; import { DEFAULT_STATS_CONFIG } from "@/types/stats-widgets"; import { Checkbox } from "@/components/ui/checkbox.tsx"; @@ -77,11 +77,9 @@ export function HostManagerEditor({ onFormSubmit, }: SSHManagerHostEditorProps) { const { t } = useTranslation(); - const [hosts, setHosts] = useState([]); const [folders, setFolders] = useState([]); const [sshConfigurations, setSshConfigurations] = useState([]); const [credentials, setCredentials] = useState([]); - const [loading, setLoading] = useState(true); const [authTab, setAuthTab] = useState<"password" | "key" | "credential">( "password", @@ -96,12 +94,10 @@ export function HostManagerEditor({ useEffect(() => { const fetchData = async () => { try { - setLoading(true); const [hostsData, credentialsData] = await Promise.all([ getSSHHosts(), getCredentials(), ]); - setHosts(hostsData); setCredentials(credentialsData); const uniqueFolders = [ @@ -124,8 +120,6 @@ export function HostManagerEditor({ setSshConfigurations(uniqueConfigurations); } catch { // Failed to load hosts data - } finally { - setLoading(false); } }; @@ -135,9 +129,7 @@ export function HostManagerEditor({ useEffect(() => { const handleCredentialChange = async () => { try { - setLoading(true); const hostsData = await getSSHHosts(); - setHosts(hostsData); const uniqueFolders = [ ...new Set( @@ -159,8 +151,6 @@ export function HostManagerEditor({ setSshConfigurations(uniqueConfigurations); } catch { // Failed to reload hosts after credential change - } finally { - setLoading(false); } }; @@ -533,7 +523,7 @@ export function HostManagerEditor({ window.dispatchEvent(new CustomEvent("ssh-hosts:changed")); form.reset(); - } catch (error) { + } catch { toast.error(t("hosts.failedToSaveHost")); } finally { isSubmittingRef.current = false; diff --git a/src/ui/Desktop/Apps/Host Manager/HostManagerViewer.tsx b/src/ui/Desktop/Apps/Host Manager/HostManagerViewer.tsx index 0c0dd870..6575c396 100644 --- a/src/ui/Desktop/Apps/Host Manager/HostManagerViewer.tsx +++ b/src/ui/Desktop/Apps/Host Manager/HostManagerViewer.tsx @@ -106,7 +106,7 @@ export function HostManagerViewer({ onEditHost }: SSHManagerHostViewerProps) { setHosts(cleanedHosts); setError(null); - } catch (err) { + } catch { setError(t("hosts.failedToLoadHosts")); } finally { setLoading(false); @@ -122,7 +122,7 @@ export function HostManagerViewer({ onEditHost }: SSHManagerHostViewerProps) { toast.success(t("hosts.hostDeletedSuccessfully", { name: hostName })); await fetchHosts(); window.dispatchEvent(new CustomEvent("ssh-hosts:changed")); - } catch (err) { + } catch { toast.error(t("hosts.failedToDeleteHost")); } }, @@ -143,7 +143,7 @@ export function HostManagerViewer({ onEditHost }: SSHManagerHostViewerProps) { }); confirmWithToast(confirmMessage, () => { - performExport(host, actualAuthType); + performExport(host); }); return; } else if (actualAuthType === "password" || actualAuthType === "key") { @@ -152,21 +152,21 @@ export function HostManagerViewer({ onEditHost }: SSHManagerHostViewerProps) { }); confirmWithToast(confirmMessage, () => { - performExport(host, actualAuthType); + performExport(host); }); return; } - performExport(host, actualAuthType); + performExport(host); }; - const performExport = async (host: SSHHost, actualAuthType: string) => { + const performExport = async (host: SSHHost) => { try { const decryptedHost = await exportSSHHostWithCredentials(host.id); const cleanExportData = Object.fromEntries( Object.entries(decryptedHost).filter( - ([_, value]) => value !== undefined, + ([, value]) => value !== undefined, ), ); @@ -185,7 +185,7 @@ export function HostManagerViewer({ onEditHost }: SSHManagerHostViewerProps) { toast.success( `Exported host configuration for ${host.name || host.username}@${host.ip}`, ); - } catch (error) { + } catch { toast.error(t("hosts.failedToExportHost")); } }; @@ -222,7 +222,7 @@ export function HostManagerViewer({ onEditHost }: SSHManagerHostViewerProps) { ); await fetchHosts(); window.dispatchEvent(new CustomEvent("ssh-hosts:changed")); - } catch (err) { + } catch { toast.error(t("hosts.failedToRemoveFromFolder")); } finally { setOperationLoading(false); @@ -251,7 +251,7 @@ export function HostManagerViewer({ onEditHost }: SSHManagerHostViewerProps) { window.dispatchEvent(new CustomEvent("ssh-hosts:changed")); setEditingFolder(null); setEditingFolderName(""); - } catch (err) { + } catch { toast.error(t("hosts.failedToRenameFolder")); } finally { setOperationLoading(false); @@ -291,7 +291,7 @@ export function HostManagerViewer({ onEditHost }: SSHManagerHostViewerProps) { setDragOverFolder(folderName); }; - const handleDragLeave = (e: React.DragEvent) => { + const handleDragLeave = () => { dragCounter.current--; if (dragCounter.current === 0) { setDragOverFolder(null); @@ -325,7 +325,7 @@ export function HostManagerViewer({ onEditHost }: SSHManagerHostViewerProps) { ); await fetchHosts(); window.dispatchEvent(new CustomEvent("ssh-hosts:changed")); - } catch (err) { + } catch { toast.error(t("hosts.failedToMoveToFolder")); } finally { setOperationLoading(false); diff --git a/src/ui/Desktop/Apps/Server/Server.tsx b/src/ui/Desktop/Apps/Server/Server.tsx index 9996c359..4cbc48a7 100644 --- a/src/ui/Desktop/Apps/Server/Server.tsx +++ b/src/ui/Desktop/Apps/Server/Server.tsx @@ -148,7 +148,7 @@ export function Server({ if (updatedHost) { setCurrentHostConfig(updatedHost); } - } catch (error) { + } catch { toast.error(t("serverStats.failedToFetchHostConfig")); } } @@ -165,7 +165,7 @@ export function Server({ if (updatedHost) { setCurrentHostConfig(updatedHost); } - } catch (error) { + } catch { toast.error(t("serverStats.failedToFetchHostConfig")); } }