mirror of
https://github.com/everoddandeven/monerod-gui.git
synced 2024-12-22 11:39:25 +00:00
Auto launch methods implementation
This commit is contained in:
parent
bca3bee129
commit
d306c11086
7 changed files with 351 additions and 2 deletions
95
app/main.ts
95
app/main.ts
|
@ -8,6 +8,9 @@ import * as tar from 'tar';
|
|||
import * as os from 'os';
|
||||
import * as pidusage from 'pidusage';
|
||||
|
||||
const AutoLaunch = require('auto-launch');
|
||||
|
||||
|
||||
interface Stats {
|
||||
/**
|
||||
* percentage (from 0 to 100*vcore)
|
||||
|
@ -57,6 +60,11 @@ if (!gotInstanceLock) {
|
|||
app.quit();
|
||||
}
|
||||
|
||||
const autoLauncher = new AutoLaunch({
|
||||
name: 'Monero Daemon'
|
||||
});
|
||||
|
||||
|
||||
|
||||
let win: BrowserWindow | null = null;
|
||||
let isHidden: boolean = false;
|
||||
|
@ -176,6 +184,13 @@ function createWindow(): BrowserWindow {
|
|||
return win;
|
||||
}
|
||||
|
||||
// #region Auto Launch
|
||||
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region WiFi
|
||||
|
||||
function isConnectedToWiFi(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const platform = os.platform(); // Use os to get the platform
|
||||
|
@ -231,6 +246,10 @@ function isWifiConnected() {
|
|||
});
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region monerod
|
||||
|
||||
function getMonerodVersion(monerodFilePath: string): void {
|
||||
const monerodProcess = spawn(monerodFilePath, [ '--version' ]);
|
||||
|
||||
|
@ -348,6 +367,10 @@ function monitorMonerod(): void {
|
|||
});
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region Download Utils
|
||||
|
||||
const downloadFile = (url: string, destinationDir: string, onProgress: (progress: number) => void): Promise<string> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = (url: string) => {
|
||||
|
@ -490,6 +513,8 @@ const extractTarBz2 = (filePath: string, destination: string): Promise<string> =
|
|||
});
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
function showNotification(options?: NotificationConstructorOptions): void {
|
||||
if (!options) {
|
||||
return;
|
||||
|
@ -632,6 +657,76 @@ try {
|
|||
showNotification(options);
|
||||
});
|
||||
|
||||
ipcMain.handle('is-auto-launch-enabled', (event: IpcMainInvokeEvent) => {
|
||||
autoLauncher.isEnabled().then((enabled: boolean) => {
|
||||
win?.webContents.send('on-is-auto-launch-enabled', enabled);
|
||||
}).catch((error: any) => {
|
||||
console.error(error);
|
||||
win?.webContents.send('on-is-auto-launch-enabled', false);
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.handle('enable-auto-launch', (event:IpcMainInvokeEvent) => {
|
||||
autoLauncher.isEnabled().then((enabled: boolean) => {
|
||||
if (enabled) {
|
||||
win?.webContents.send('on-enable-auto-launch-error', 'already enabled');
|
||||
return;
|
||||
}
|
||||
|
||||
autoLauncher.enable().then(() => {
|
||||
autoLauncher.isEnabled().then((enabled: boolean) => {
|
||||
if (enabled) {
|
||||
win?.webContents.send('on-enable-auto-launch-success');
|
||||
}
|
||||
win?.webContents.send('on-enable-auto-launch-error', `Could not enabled auto launch`);
|
||||
}).catch((error: any) => {
|
||||
win?.webContents.send('on-enable-auto-launch-error', `${error}`);
|
||||
});
|
||||
|
||||
}).catch((error: any) => {
|
||||
console.error(error);
|
||||
win?.webContents.send('on-enable-auto-launch-error', `${error}`);
|
||||
});
|
||||
}).catch((error: any) => {
|
||||
console.error(error);
|
||||
win?.webContents.send('on-enable-auto-launch-error', `${error}`);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
ipcMain.handle('disable-auto-launch', (event:IpcMainInvokeEvent) => {
|
||||
autoLauncher.isEnabled().then((enabled: boolean) => {
|
||||
if (!enabled) {
|
||||
win?.webContents.send('on-disable-auto-launch-error', 'already disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
autoLauncher.disable().then(() => {
|
||||
autoLauncher.isEnabled().then((enabled: boolean) => {
|
||||
if (!enabled) {
|
||||
win?.webContents.send('on-disable-auto-launch-success');
|
||||
}
|
||||
win?.webContents.send('on-disable-auto-launch-error', `Could not disable auto launch`);
|
||||
}).catch((error: any) => {
|
||||
win?.webContents.send('on-disable-auto-launch-error', `${error}`);
|
||||
});
|
||||
|
||||
}).catch((error: any) => {
|
||||
console.error(error);
|
||||
win?.webContents.send('on-disable-auto-launch-error', `${error}`);
|
||||
});
|
||||
}).catch((error: any) => {
|
||||
console.error(error);
|
||||
win?.webContents.send('on-disable-auto-launch-error', `${error}`);
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.handle('is-app-image', (event: IpcMainInvokeEvent) => {
|
||||
const isAppImage: boolean = !!process.env.APPIMAGE;
|
||||
|
||||
win?.webContents.send('on-is-app-image', isAppImage ? true : false);
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
// Catch Error
|
||||
console.error(e);
|
||||
|
|
121
app/package-lock.json
generated
121
app/package-lock.json
generated
|
@ -8,12 +8,14 @@
|
|||
"name": "monerod-gui",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"auto-launch": "^5.0.6",
|
||||
"os": "^0.1.2",
|
||||
"pidusage": "^3.0.2",
|
||||
"tar": "^7.4.3",
|
||||
"unbzip2-stream": "^1.4.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/auto-launch": "^5.0.5",
|
||||
"@types/pidusage": "^2.0.5"
|
||||
}
|
||||
},
|
||||
|
@ -53,6 +55,12 @@
|
|||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/auto-launch": {
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/auto-launch/-/auto-launch-5.0.5.tgz",
|
||||
"integrity": "sha512-/nGvQZSzM/pvCMCh4Gt2kIeiUmOP/cKGJbjlInI+A+5MoV/7XmT56DJ6EU8bqc3+ItxEe4UC2GVspmPzcCc8cg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/pidusage": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/pidusage/-/pidusage-2.0.5.tgz",
|
||||
|
@ -81,6 +89,37 @@
|
|||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/applescript": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/applescript/-/applescript-1.0.0.tgz",
|
||||
"integrity": "sha512-yvtNHdWvtbYEiIazXAdp/NY+BBb65/DAseqlNiJQjOx9DynuzOYDbVLBJvuc0ve0VL9x6B3OHF6eH52y9hCBtQ=="
|
||||
},
|
||||
"node_modules/auto-launch": {
|
||||
"version": "5.0.6",
|
||||
"resolved": "https://registry.npmjs.org/auto-launch/-/auto-launch-5.0.6.tgz",
|
||||
"integrity": "sha512-OgxiAm4q9EBf9EeXdPBiVNENaWE3jUZofwrhAkWjHDYGezu1k3FRZHU8V2FBxGuSJOHzKmTJEd0G7L7/0xDGFA==",
|
||||
"dependencies": {
|
||||
"applescript": "^1.0.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"path-is-absolute": "^1.0.0",
|
||||
"untildify": "^3.0.2",
|
||||
"winreg": "1.2.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/auto-launch/node_modules/mkdirp": {
|
||||
"version": "0.5.6",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
||||
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.6"
|
||||
},
|
||||
"bin": {
|
||||
"mkdirp": "bin/cmd.js"
|
||||
}
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
|
@ -282,6 +321,14 @@
|
|||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/minimist": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/minipass": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
|
||||
|
@ -326,6 +373,14 @@
|
|||
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
|
||||
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw=="
|
||||
},
|
||||
"node_modules/path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/path-key": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
||||
|
@ -541,6 +596,14 @@
|
|||
"through": "^2.3.8"
|
||||
}
|
||||
},
|
||||
"node_modules/untildify": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/untildify/-/untildify-3.0.3.tgz",
|
||||
"integrity": "sha512-iSk/J8efr8uPT/Z4eSUywnqyrQU7DSdMfdqK4iWEaUVVmcP5JcnpRqmVMwcwcnmI1ATFNgC5V90u09tBynNFKA==",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
@ -555,6 +618,11 @@
|
|||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/winreg": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/winreg/-/winreg-1.2.4.tgz",
|
||||
"integrity": "sha512-IHpzORub7kYlb8A43Iig3reOvlcBJGX9gZ0WycHhghHtA65X0LYnMRuJs+aH1abVnMJztQkvQNlltnbPi5aGIA=="
|
||||
},
|
||||
"node_modules/wrap-ansi": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
|
||||
|
@ -676,6 +744,12 @@
|
|||
"integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==",
|
||||
"optional": true
|
||||
},
|
||||
"@types/auto-launch": {
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/auto-launch/-/auto-launch-5.0.5.tgz",
|
||||
"integrity": "sha512-/nGvQZSzM/pvCMCh4Gt2kIeiUmOP/cKGJbjlInI+A+5MoV/7XmT56DJ6EU8bqc3+ItxEe4UC2GVspmPzcCc8cg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/pidusage": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/pidusage/-/pidusage-2.0.5.tgz",
|
||||
|
@ -692,6 +766,33 @@
|
|||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz",
|
||||
"integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug=="
|
||||
},
|
||||
"applescript": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/applescript/-/applescript-1.0.0.tgz",
|
||||
"integrity": "sha512-yvtNHdWvtbYEiIazXAdp/NY+BBb65/DAseqlNiJQjOx9DynuzOYDbVLBJvuc0ve0VL9x6B3OHF6eH52y9hCBtQ=="
|
||||
},
|
||||
"auto-launch": {
|
||||
"version": "5.0.6",
|
||||
"resolved": "https://registry.npmjs.org/auto-launch/-/auto-launch-5.0.6.tgz",
|
||||
"integrity": "sha512-OgxiAm4q9EBf9EeXdPBiVNENaWE3jUZofwrhAkWjHDYGezu1k3FRZHU8V2FBxGuSJOHzKmTJEd0G7L7/0xDGFA==",
|
||||
"requires": {
|
||||
"applescript": "^1.0.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"path-is-absolute": "^1.0.0",
|
||||
"untildify": "^3.0.2",
|
||||
"winreg": "1.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"mkdirp": {
|
||||
"version": "0.5.6",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
||||
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
||||
"requires": {
|
||||
"minimist": "^1.2.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
|
@ -816,6 +917,11 @@
|
|||
"brace-expansion": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="
|
||||
},
|
||||
"minipass": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
|
||||
|
@ -845,6 +951,11 @@
|
|||
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
|
||||
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw=="
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg=="
|
||||
},
|
||||
"path-key": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
||||
|
@ -988,6 +1099,11 @@
|
|||
"through": "^2.3.8"
|
||||
}
|
||||
},
|
||||
"untildify": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/untildify/-/untildify-3.0.3.tgz",
|
||||
"integrity": "sha512-iSk/J8efr8uPT/Z4eSUywnqyrQU7DSdMfdqK4iWEaUVVmcP5JcnpRqmVMwcwcnmI1ATFNgC5V90u09tBynNFKA=="
|
||||
},
|
||||
"which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
@ -996,6 +1112,11 @@
|
|||
"isexe": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"winreg": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/winreg/-/winreg-1.2.4.tgz",
|
||||
"integrity": "sha512-IHpzORub7kYlb8A43Iig3reOvlcBJGX9gZ0WycHhghHtA65X0LYnMRuJs+aH1abVnMJztQkvQNlltnbPi5aGIA=="
|
||||
},
|
||||
"wrap-ansi": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
|
||||
|
|
|
@ -10,12 +10,14 @@
|
|||
"main": "main.js",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"auto-launch": "^5.0.6",
|
||||
"os": "^0.1.2",
|
||||
"pidusage": "^3.0.2",
|
||||
"tar": "^7.4.3",
|
||||
"unbzip2-stream": "^1.4.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/auto-launch": "^5.0.5",
|
||||
"@types/pidusage": "^2.0.5"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,5 +81,35 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||
},
|
||||
quit: () => {
|
||||
ipcRenderer.invoke('quit');
|
||||
},
|
||||
enableAutoLaunch: () => {
|
||||
ipcRenderer.invoke('enable-auto-launch');
|
||||
},
|
||||
isAutoLaunchEnabled: () => {
|
||||
ipcRenderer.invoke('is-auto-launch-enabled');
|
||||
},
|
||||
onIsAutoLaunchEnabled: (callback) => {
|
||||
ipcRenderer.on('on-is-auto-enabled', callback);
|
||||
},
|
||||
onEnableAutoLaunchError: (callback) => {
|
||||
ipcRenderer.on('on-enable-auto-launch-error', callback);
|
||||
},
|
||||
onEnableAutoLaunchSuccess: (callback) => {
|
||||
ipcRenderer.on('on-enable-auto-launch-success', callback);
|
||||
},
|
||||
disableAutoLaunch: () => {
|
||||
ipcRenderer.invoke('disable-auto-launch');
|
||||
},
|
||||
onDisableAutoLaunchError: (callback) => {
|
||||
ipcRenderer.on('on-disable-auto-launch-error', callback);
|
||||
},
|
||||
onDisableAutoLaunchSuccess: (callback) => {
|
||||
ipcRenderer.on('on-disable-auto-launch-success', callback);
|
||||
},
|
||||
isAppImage: () => {
|
||||
ipcRenderer.invoke('is-app-image');
|
||||
},
|
||||
onIsAppImage: (callback) => {
|
||||
ipcRenderer.on('on-is-app-image', callback);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
"linux": {
|
||||
"icon": "dist/assets/icons",
|
||||
"target": [
|
||||
"AppImage"
|
||||
"AppImage",
|
||||
"deb"
|
||||
],
|
||||
"category": "Network"
|
||||
}
|
||||
|
|
|
@ -53,4 +53,90 @@ export class ElectronService {
|
|||
get isElectron(): boolean {
|
||||
return !!(window && window.process && window.process.type);
|
||||
}
|
||||
|
||||
public async isAutoLaunchEnabled(): Promise<boolean> {
|
||||
if (await this.isAppImage()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const promise = new Promise<boolean>((resolve) => {
|
||||
window.electronAPI.onIsAutoLaunchEnabled((event: any, enabled: boolean) => {
|
||||
resolve(enabled);
|
||||
});
|
||||
});
|
||||
|
||||
window.electronAPI.isAutoLaunchEnabled();
|
||||
|
||||
return await promise;
|
||||
}
|
||||
|
||||
public async enableAutoLaunch(): Promise<void> {
|
||||
if (await this.isAppImage()) {
|
||||
throw new Error("Cannot enable auto launch");
|
||||
}
|
||||
|
||||
const enabled = await this.isAutoLaunchEnabled();
|
||||
|
||||
if (enabled) {
|
||||
throw new Error("Auto launch already enabled");
|
||||
}
|
||||
|
||||
const promise = new Promise<void>((resolve, reject) => {
|
||||
window.electronAPI.onEnableAutoLaunchError((event: any, error: string) => {
|
||||
console.debug(event);
|
||||
reject(error);
|
||||
});
|
||||
|
||||
window.electronAPI.onEnableAutoLaunchSuccess((event: any) => {
|
||||
console.debug(event);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
window.electronAPI.enableAutoLaunch();
|
||||
|
||||
await promise;
|
||||
}
|
||||
|
||||
|
||||
public async disableAutoLaunch(): Promise<void> {
|
||||
if (await this.isAppImage()) {
|
||||
throw new Error("Cannot disable auto launch");
|
||||
}
|
||||
|
||||
const enabled = await this.isAutoLaunchEnabled();
|
||||
|
||||
if (!enabled) {
|
||||
throw new Error("Auto launch already disabled");
|
||||
}
|
||||
|
||||
const promise = new Promise<void>((resolve, reject) => {
|
||||
window.electronAPI.onDisableAutoLaunchError((event: any, error: string) => {
|
||||
console.debug(event);
|
||||
reject(error);
|
||||
});
|
||||
|
||||
window.electronAPI.onDisableAutoLaunchSuccess((event: any) => {
|
||||
console.debug(event);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
window.electronAPI.disableAutoLaunch();
|
||||
|
||||
await promise;
|
||||
}
|
||||
|
||||
public async isAppImage(): Promise<boolean> {
|
||||
const promise = new Promise<boolean>((resolve) => {
|
||||
window.electronAPI.onIsAppImage((event: any, value: boolean) => {
|
||||
resolve(value);
|
||||
});
|
||||
});
|
||||
|
||||
window.electronAPI.isAppImage();
|
||||
|
||||
return await promise;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -93,7 +93,21 @@ declare global {
|
|||
gotOsType: (callback: (event: any, osType: { platform: string, arch: string }) => void) => void;
|
||||
showNotification: (options: NotificationConstructorOptions) => void;
|
||||
quit: () => void;
|
||||
|
||||
|
||||
isAppImage: () => void;
|
||||
onIsAppImage: (callback: (event: any, value: boolean) => void) => void;
|
||||
|
||||
isAutoLaunchEnabled: () => void;
|
||||
onIsAutoLaunchEnabled: (callback: (event: any, enabled: boolean) => void) => void;
|
||||
|
||||
enableAutoLaunch: () => void;
|
||||
onEnableAutoLaunchError: (callback: (event: any, error: string) => void) => void;
|
||||
onEnableAutoLaunchSuccess: (callback: (event: any) => void) => void;
|
||||
|
||||
disableAutoLaunch: () => void;
|
||||
onDisableAutoLaunchError: (callback: (event: any, error: string) => void) => void;
|
||||
onDisableAutoLaunchSuccess: (callback: (event: any) => void) => void;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue