refactor: cleanup

This commit is contained in:
zhom
2026-05-29 06:31:42 +04:00
parent 17e33aa53f
commit ecafb5e1c0
40 changed files with 484 additions and 2344 deletions
+19 -1
View File
@@ -15,7 +15,7 @@ import {
import { RippleButton } from "./ui/ripple";
export function CloseConfirmDialog() {
const { t } = useTranslation();
const { t, i18n } = useTranslation();
const [isOpen, setIsOpen] = useState(false);
useEffect(() => {
@@ -29,6 +29,24 @@ export function CloseConfirmDialog() {
};
}, []);
// The native tray menu is built in Rust and cannot read the active language,
// so push localized labels to it on mount and whenever the language changes.
useEffect(() => {
const syncTrayMenu = () => {
void invoke("update_tray_menu", {
showLabel: t("tray.show"),
quitLabel: t("tray.quit"),
}).catch(() => {
// Tray is desktop-only; ignore on platforms without one.
});
};
syncTrayMenu();
i18n.on("languageChanged", syncTrayMenu);
return () => {
i18n.off("languageChanged", syncTrayMenu);
};
}, [t, i18n]);
const handleMinimize = async () => {
setIsOpen(false);
try {
-106
View File
@@ -1,106 +0,0 @@
"use client";
import { invoke } from "@tauri-apps/api/core";
import { useCallback, useState } from "react";
import { useTranslation } from "react-i18next";
import { LoadingButton } from "@/components/loading-button";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { showErrorToast, showSuccessToast } from "@/lib/toast-utils";
interface LaunchOnLoginDialogProps {
isOpen: boolean;
onClose: () => void;
}
export function LaunchOnLoginDialog({
isOpen,
onClose,
}: LaunchOnLoginDialogProps) {
const { t } = useTranslation();
const [isEnabling, setIsEnabling] = useState(false);
const [isDeclining, setIsDeclining] = useState(false);
const handleEnable = useCallback(async () => {
setIsEnabling(true);
try {
await invoke("enable_launch_on_login");
showSuccessToast(t("launchOnLogin.enableSuccess"));
onClose();
} catch (error) {
console.error("Failed to enable launch on login:", error);
showErrorToast(t("launchOnLogin.enableFailed"), {
description:
error instanceof Error ? error.message : t("launchOnLogin.tryAgain"),
});
} finally {
setIsEnabling(false);
}
}, [onClose, t]);
const handleDecline = useCallback(async () => {
setIsDeclining(true);
try {
await invoke("decline_launch_on_login");
onClose();
} catch (error) {
console.error("Failed to decline launch on login:", error);
showErrorToast(t("launchOnLogin.declineFailed"), {
description:
error instanceof Error ? error.message : t("launchOnLogin.tryAgain"),
});
} finally {
setIsDeclining(false);
}
}, [onClose, t]);
return (
<Dialog open={isOpen}>
<DialogContent
className="sm:max-w-sm"
onEscapeKeyDown={(e) => {
e.preventDefault();
}}
onPointerDownOutside={(e) => {
e.preventDefault();
}}
onInteractOutside={(e) => {
e.preventDefault();
}}
>
<DialogHeader>
<DialogTitle>{t("launchOnLogin.title")}</DialogTitle>
</DialogHeader>
<p className="text-sm text-muted-foreground">
{t("launchOnLogin.description")}
</p>
<DialogFooter className="flex-row justify-between sm:justify-between">
<Button
variant="ghost"
onClick={handleDecline}
disabled={isEnabling || isDeclining}
>
{isDeclining
? t("launchOnLogin.declining")
: t("launchOnLogin.declineButton")}
</Button>
<LoadingButton
onClick={handleEnable}
isLoading={isEnabling}
disabled={isDeclining}
>
{t("launchOnLogin.enableButton")}
</LoadingButton>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
+81 -31
View File
@@ -422,7 +422,9 @@ export function SharedCamoufoxConfigForm({
e.target.value || undefined,
);
}}
placeholder="Mozilla/5.0..."
placeholder={t("common.placeholders.example", {
value: "Mozilla/5.0...",
})}
/>
</div>
<div className="space-y-2">
@@ -436,7 +438,9 @@ export function SharedCamoufoxConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., MacIntel, Win32"
placeholder={t("common.placeholders.example", {
value: "MacIntel, Win32",
})}
/>
</div>
<div className="space-y-2">
@@ -452,7 +456,9 @@ export function SharedCamoufoxConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., 5.0 (Macintosh)"
placeholder={t("common.placeholders.example", {
value: "5.0 (Macintosh)",
})}
/>
</div>
<div className="space-y-2">
@@ -487,7 +493,7 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 8"
placeholder={t("common.placeholders.example", { value: "8" })}
/>
</div>
<div className="space-y-2">
@@ -504,7 +510,7 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 0"
placeholder={t("common.placeholders.example", { value: "0" })}
/>
</div>
<div className="space-y-2">
@@ -549,7 +555,9 @@ export function SharedCamoufoxConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., en-US"
placeholder={t("common.placeholders.example", {
value: "en-US",
})}
/>
</div>
</div>
@@ -573,7 +581,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1920"
placeholder={t("common.placeholders.example", {
value: "1920",
})}
/>
</div>
<div className="space-y-2">
@@ -590,7 +600,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1080"
placeholder={t("common.placeholders.example", {
value: "1080",
})}
/>
</div>
<div className="space-y-2">
@@ -607,7 +619,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1920"
placeholder={t("common.placeholders.example", {
value: "1920",
})}
/>
</div>
<div className="space-y-2">
@@ -624,7 +638,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1055"
placeholder={t("common.placeholders.example", {
value: "1055",
})}
/>
</div>
<div className="space-y-2">
@@ -641,7 +657,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 30"
placeholder={t("common.placeholders.example", {
value: "30",
})}
/>
</div>
<div className="space-y-2">
@@ -658,7 +676,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 30"
placeholder={t("common.placeholders.example", {
value: "30",
})}
/>
</div>
</div>
@@ -682,7 +702,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1512"
placeholder={t("common.placeholders.example", {
value: "1512",
})}
/>
</div>
<div className="space-y-2">
@@ -699,7 +721,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 886"
placeholder={t("common.placeholders.example", {
value: "886",
})}
/>
</div>
<div className="space-y-2">
@@ -716,7 +740,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1512"
placeholder={t("common.placeholders.example", {
value: "1512",
})}
/>
</div>
<div className="space-y-2">
@@ -733,7 +759,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 886"
placeholder={t("common.placeholders.example", {
value: "886",
})}
/>
</div>
<div className="space-y-2">
@@ -748,7 +776,7 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 0"
placeholder={t("common.placeholders.example", { value: "0" })}
/>
</div>
<div className="space-y-2">
@@ -763,7 +791,7 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 0"
placeholder={t("common.placeholders.example", { value: "0" })}
/>
</div>
</div>
@@ -786,7 +814,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseFloat(e.target.value) : undefined,
);
}}
placeholder="e.g., 41.0019"
placeholder={t("common.placeholders.example", {
value: "41.0019",
})}
/>
</div>
<div className="space-y-2">
@@ -802,7 +832,9 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseFloat(e.target.value) : undefined,
);
}}
placeholder="e.g., 28.9645"
placeholder={t("common.placeholders.example", {
value: "28.9645",
})}
/>
</div>
<div className="space-y-2">
@@ -817,7 +849,9 @@ export function SharedCamoufoxConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., America/New_York"
placeholder={t("common.placeholders.example", {
value: "America/New_York",
})}
/>
</div>
</div>
@@ -840,7 +874,9 @@ export function SharedCamoufoxConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., tr"
placeholder={t("common.placeholders.example", {
value: "tr",
})}
/>
</div>
<div className="space-y-2">
@@ -854,7 +890,9 @@ export function SharedCamoufoxConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., TR"
placeholder={t("common.placeholders.example", {
value: "TR",
})}
/>
</div>
<div className="space-y-2">
@@ -868,7 +906,9 @@ export function SharedCamoufoxConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., Latn"
placeholder={t("common.placeholders.example", {
value: "Latn",
})}
/>
</div>
</div>
@@ -891,7 +931,9 @@ export function SharedCamoufoxConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., Mesa"
placeholder={t("common.placeholders.example", {
value: "Mesa",
})}
/>
</div>
<div className="space-y-2">
@@ -1053,7 +1095,7 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseFloat(e.target.value) : undefined,
);
}}
placeholder="e.g., 0"
placeholder={t("common.placeholders.example", { value: "0" })}
/>
</div>
<div className="space-y-2">
@@ -1071,7 +1113,7 @@ export function SharedCamoufoxConfigForm({
e.target.value ? parseFloat(e.target.value) : undefined,
);
}}
placeholder="e.g., 0"
placeholder={t("common.placeholders.example", { value: "0" })}
/>
</div>
</div>
@@ -1240,7 +1282,9 @@ export function SharedCamoufoxConfigForm({
: undefined,
);
}}
placeholder="e.g., 1920"
placeholder={t("common.placeholders.example", {
value: "1920",
})}
/>
</div>
<div className="space-y-2">
@@ -1259,7 +1303,9 @@ export function SharedCamoufoxConfigForm({
: undefined,
);
}}
placeholder="e.g., 1080"
placeholder={t("common.placeholders.example", {
value: "1080",
})}
/>
</div>
<div className="space-y-2">
@@ -1278,7 +1324,9 @@ export function SharedCamoufoxConfigForm({
: undefined,
);
}}
placeholder="e.g., 800"
placeholder={t("common.placeholders.example", {
value: "800",
})}
/>
</div>
<div className="space-y-2">
@@ -1297,7 +1345,9 @@ export function SharedCamoufoxConfigForm({
: undefined,
);
}}
placeholder="e.g., 600"
placeholder={t("common.placeholders.example", {
value: "600",
})}
/>
</div>
</div>
+90 -34
View File
@@ -302,7 +302,9 @@ export function WayfernConfigForm({
e.target.value || undefined,
);
}}
placeholder="Mozilla/5.0..."
placeholder={t("common.placeholders.example", {
value: "Mozilla/5.0...",
})}
/>
</div>
<div className="space-y-2">
@@ -334,7 +336,9 @@ export function WayfernConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., 10.0.0"
placeholder={t("common.placeholders.example", {
value: "10.0.0",
})}
/>
</div>
<div className="space-y-2">
@@ -348,7 +352,9 @@ export function WayfernConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., Google Chrome"
placeholder={t("common.placeholders.example", {
value: "Google Chrome",
})}
/>
</div>
<div className="space-y-2">
@@ -364,7 +370,9 @@ export function WayfernConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., 143"
placeholder={t("common.placeholders.example", {
value: "143",
})}
/>
</div>
</div>
@@ -388,7 +396,7 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 8"
placeholder={t("common.placeholders.example", { value: "8" })}
/>
</div>
<div className="space-y-2">
@@ -405,7 +413,7 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 0"
placeholder={t("common.placeholders.example", { value: "0" })}
/>
</div>
<div className="space-y-2">
@@ -422,7 +430,7 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 8"
placeholder={t("common.placeholders.example", { value: "8" })}
/>
</div>
</div>
@@ -446,7 +454,9 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1920"
placeholder={t("common.placeholders.example", {
value: "1920",
})}
/>
</div>
<div className="space-y-2">
@@ -463,7 +473,9 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1080"
placeholder={t("common.placeholders.example", {
value: "1080",
})}
/>
</div>
<div className="space-y-2">
@@ -481,7 +493,9 @@ export function WayfernConfigForm({
e.target.value ? parseFloat(e.target.value) : undefined,
);
}}
placeholder="e.g., 1.0"
placeholder={t("common.placeholders.example", {
value: "1.0",
})}
/>
</div>
<div className="space-y-2">
@@ -498,7 +512,9 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1920"
placeholder={t("common.placeholders.example", {
value: "1920",
})}
/>
</div>
<div className="space-y-2">
@@ -515,7 +531,9 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1040"
placeholder={t("common.placeholders.example", {
value: "1040",
})}
/>
</div>
<div className="space-y-2">
@@ -532,7 +550,9 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 24"
placeholder={t("common.placeholders.example", {
value: "24",
})}
/>
</div>
</div>
@@ -556,7 +576,9 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1920"
placeholder={t("common.placeholders.example", {
value: "1920",
})}
/>
</div>
<div className="space-y-2">
@@ -573,7 +595,9 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1040"
placeholder={t("common.placeholders.example", {
value: "1040",
})}
/>
</div>
<div className="space-y-2">
@@ -590,7 +614,9 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 1920"
placeholder={t("common.placeholders.example", {
value: "1920",
})}
/>
</div>
<div className="space-y-2">
@@ -607,7 +633,9 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 940"
placeholder={t("common.placeholders.example", {
value: "940",
})}
/>
</div>
<div className="space-y-2">
@@ -622,7 +650,7 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 0"
placeholder={t("common.placeholders.example", { value: "0" })}
/>
</div>
<div className="space-y-2">
@@ -637,7 +665,7 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 0"
placeholder={t("common.placeholders.example", { value: "0" })}
/>
</div>
</div>
@@ -660,7 +688,9 @@ export function WayfernConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., en-US"
placeholder={t("common.placeholders.example", {
value: "en-US",
})}
/>
</div>
<div className="space-y-2">
@@ -740,7 +770,9 @@ export function WayfernConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., America/New_York"
placeholder={t("common.placeholders.example", {
value: "America/New_York",
})}
/>
</div>
<div className="space-y-2">
@@ -775,7 +807,9 @@ export function WayfernConfigForm({
e.target.value ? parseFloat(e.target.value) : undefined,
);
}}
placeholder="e.g., 40.7128"
placeholder={t("common.placeholders.example", {
value: "40.7128",
})}
/>
</div>
<div className="space-y-2">
@@ -791,7 +825,9 @@ export function WayfernConfigForm({
e.target.value ? parseFloat(e.target.value) : undefined,
);
}}
placeholder="e.g., -74.0060"
placeholder={t("common.placeholders.example", {
value: "-74.0060",
})}
/>
</div>
<div className="space-y-2">
@@ -806,7 +842,9 @@ export function WayfernConfigForm({
e.target.value ? parseFloat(e.target.value) : undefined,
);
}}
placeholder="e.g., 100"
placeholder={t("common.placeholders.example", {
value: "100",
})}
/>
</div>
</div>
@@ -829,7 +867,9 @@ export function WayfernConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., Intel"
placeholder={t("common.placeholders.example", {
value: "Intel",
})}
/>
</div>
<div className="space-y-2">
@@ -926,7 +966,9 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 48000"
placeholder={t("common.placeholders.example", {
value: "48000",
})}
/>
</div>
<div className="space-y-2">
@@ -943,7 +985,7 @@ export function WayfernConfigForm({
e.target.value ? parseInt(e.target.value, 10) : undefined,
);
}}
placeholder="e.g., 2"
placeholder={t("common.placeholders.example", { value: "2" })}
/>
</div>
</div>
@@ -987,7 +1029,9 @@ export function WayfernConfigForm({
e.target.value ? parseFloat(e.target.value) : undefined,
);
}}
placeholder="e.g., 0.85"
placeholder={t("common.placeholders.example", {
value: "0.85",
})}
/>
</div>
</div>
@@ -1008,7 +1052,9 @@ export function WayfernConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., Google Inc."
placeholder={t("common.placeholders.example", {
value: "Google Inc.",
})}
/>
</div>
<div className="space-y-2">
@@ -1038,7 +1084,9 @@ export function WayfernConfigForm({
e.target.value || undefined,
);
}}
placeholder="e.g., 20030107"
placeholder={t("common.placeholders.example", {
value: "20030107",
})}
/>
</div>
</div>
@@ -1197,7 +1245,9 @@ export function WayfernConfigForm({
: undefined,
);
}}
placeholder="e.g., 1920"
placeholder={t("common.placeholders.example", {
value: "1920",
})}
/>
</div>
<div className="space-y-2">
@@ -1216,7 +1266,9 @@ export function WayfernConfigForm({
: undefined,
);
}}
placeholder="e.g., 1080"
placeholder={t("common.placeholders.example", {
value: "1080",
})}
/>
</div>
<div className="space-y-2">
@@ -1235,7 +1287,9 @@ export function WayfernConfigForm({
: undefined,
);
}}
placeholder="e.g., 800"
placeholder={t("common.placeholders.example", {
value: "800",
})}
/>
</div>
<div className="space-y-2">
@@ -1254,7 +1308,9 @@ export function WayfernConfigForm({
: undefined,
);
}}
placeholder="e.g., 600"
placeholder={t("common.placeholders.example", {
value: "600",
})}
/>
</div>
</div>