fix: App Autostart (#68)

Signed-off-by: Mihai <cristian@mihaimuresan.com>
Co-authored-by: Mihai <cristian@mihaimuresan.com>
This commit is contained in:
Mihai
2026-02-13 06:25:05 +01:00
committed by GitHub
parent 3bf697d1a9
commit 127d1430a9
2 changed files with 18 additions and 15 deletions
+16 -12
View File
@@ -8,16 +8,20 @@ export const autoLaunch = new AutoLaunch({
name: "Stoat",
});
ipcMain.on("isAutostart?", () =>
autoLaunch
.isEnabled()
.then((enabled) => mainWindow.webContents.send("isAutostart", enabled)),
);
ipcMain.on("setAutostart", (_event, state: boolean) => {
if (state) {
autoLaunch.enable();
} else {
autoLaunch.disable();
}
ipcMain.handle("getAutostart", async () => {
const enabled = await autoLaunch.isEnabled();
return enabled;
});
ipcMain.handle("setAutostart", async (_event, state: boolean) => {
if (state) {
await autoLaunch.enable();
console.log("Received new configuration autoStart: true");
} else {
await autoLaunch.disable();
console.log("Received new configuration autoStart: false");
}
const enabled = await autoLaunch.isEnabled();
return enabled;
});