fix: App Autostart (#68)
Signed-off-by: Mihai <cristian@mihaimuresan.com> Co-authored-by: Mihai <cristian@mihaimuresan.com>
This commit is contained in:
+16
-12
@@ -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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user