initial commit

This commit is contained in:
Hachi-R 2024-05-05 17:18:06 -03:00
parent 21296cba95
commit 5b9af9e0ea
6 changed files with 78 additions and 0 deletions

View file

@ -0,0 +1,22 @@
import AutoLaunch from "auto-launch";
export const autoLaunch = () => {
Promise.all([window.electron.getUserPreferences()]).then(
(userPreferences) => {
if (userPreferences && userPreferences.length > 0) {
const appLauncher = new AutoLaunch({
name: "Hydra",
});
if (userPreferences[0]?.startWithSystem) {
appLauncher
.enable()
.catch((err) => console.error("Error enabling auto-launch:", err));
} else {
appLauncher
.disable()
.catch((err) => console.error("Error disabling auto-launch:", err));
}
}
}
);
};

View file

@ -4,6 +4,7 @@ import { Button, CheckboxField, TextField } from "@renderer/components";
import * as styles from "./settings.css";
import { useTranslation } from "react-i18next";
import { UserPreferences } from "@types";
// import { autoLaunch } from "./auto-launch";
export function Settings() {
const [form, setForm] = useState({
@ -12,6 +13,7 @@ export function Settings() {
repackUpdatesNotificationsEnabled: false,
telemetryEnabled: false,
preferQuitInsteadOfHiding: false,
startWithSystem: false,
});
const { t } = useTranslation("settings");
@ -30,6 +32,7 @@ export function Settings() {
telemetryEnabled: userPreferences?.telemetryEnabled ?? false,
preferQuitInsteadOfHiding:
userPreferences?.preferQuitInsteadOfHiding ?? false,
startWithSystem: userPreferences?.startWithSystem ?? false,
});
});
}, []);
@ -123,6 +126,15 @@ export function Settings() {
)
}
/>
<CheckboxField
label={"autoLaunch"}
onChange={() => {
updateUserPreferences("startWithSystem", !form.startWithSystem);
// autoLaunch();
}}
checked={form.startWithSystem}
/>
</div>
</section>
);