feat: dont show auto launch on portable version

This commit is contained in:
Zamitto 2024-06-27 19:00:12 -03:00
parent 9c99e56b70
commit f1fecb684b
4 changed files with 24 additions and 8 deletions

View file

@ -104,6 +104,7 @@ declare global {
getVersion: () => Promise<string>;
ping: () => string;
getDefaultDownloadsPath: () => Promise<string>;
isPortableVersion: () => Promise<boolean>;
showOpenDialog: (
options: Electron.OpenDialogOptions
) => Promise<Electron.OpenDialogReturnValue>;

View file

@ -10,6 +10,8 @@ export function SettingsBehavior() {
(state) => state.userPreferences.value
);
const [showRunAtStartup, setShowRunAtStartup] = useState(false);
const { updateUserPreferences } = useContext(settingsContext);
const [form, setForm] = useState({
@ -28,6 +30,12 @@ export function SettingsBehavior() {
}
}, [userPreferences]);
useEffect(() => {
window.electron.isPortableVersion().then((isPortableVersion) => {
setShowRunAtStartup(!isPortableVersion);
});
}, []);
const handleChange = (values: Partial<typeof form>) => {
setForm((prev) => ({ ...prev, ...values }));
updateUserPreferences(values);
@ -45,14 +53,16 @@ export function SettingsBehavior() {
}
/>
<CheckboxField
label={t("launch_with_system")}
onChange={() => {
handleChange({ runAtStartup: !form.runAtStartup });
window.electron.autoLaunch(!form.runAtStartup);
}}
checked={form.runAtStartup}
/>
{showRunAtStartup && (
<CheckboxField
label={t("launch_with_system")}
onChange={() => {
handleChange({ runAtStartup: !form.runAtStartup });
window.electron.autoLaunch(!form.runAtStartup);
}}
checked={form.runAtStartup}
/>
)}
</>
);
}