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",
|
name: "Stoat",
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on("isAutostart?", () =>
|
ipcMain.handle("getAutostart", async () => {
|
||||||
autoLaunch
|
const enabled = await autoLaunch.isEnabled();
|
||||||
.isEnabled()
|
return enabled;
|
||||||
.then((enabled) => mainWindow.webContents.send("isAutostart", enabled)),
|
});
|
||||||
);
|
|
||||||
|
ipcMain.handle("setAutostart", async (_event, state: boolean) => {
|
||||||
ipcMain.on("setAutostart", (_event, state: boolean) => {
|
if (state) {
|
||||||
if (state) {
|
await autoLaunch.enable();
|
||||||
autoLaunch.enable();
|
console.log("Received new configuration autoStart: true");
|
||||||
} else {
|
} else {
|
||||||
autoLaunch.disable();
|
await autoLaunch.disable();
|
||||||
}
|
console.log("Received new configuration autoStart: false");
|
||||||
|
}
|
||||||
|
|
||||||
|
const enabled = await autoLaunch.isEnabled();
|
||||||
|
return enabled;
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-3
@@ -8,10 +8,9 @@ contextBridge.exposeInMainWorld("desktopConfig", {
|
|||||||
get: () => config,
|
get: () => config,
|
||||||
set: (config: DesktopConfig) => ipcRenderer.send("config", config),
|
set: (config: DesktopConfig) => ipcRenderer.send("config", config),
|
||||||
getAutostart() {
|
getAutostart() {
|
||||||
ipcRenderer.send("isAutostart?");
|
return ipcRenderer.invoke("getAutostart") as Promise<boolean>;
|
||||||
return new Promise((resolve) => ipcRenderer.once("isAutostart", resolve));
|
|
||||||
},
|
},
|
||||||
setAutostart(value: boolean) {
|
setAutostart(value: boolean) {
|
||||||
ipcRenderer.send("setAutostart", value);
|
return ipcRenderer.invoke("setAutostart", value) as Promise<boolean>;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user