From eca7f3bccb10b30b651b0851a8b4f28da64d2c98 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Mon, 23 Oct 2017 16:31:25 +0200 Subject: fix(Windows): Fix enable/disable autostart on login Fixes #17 --- src/stores/AppStore.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 42ec25204..28fe14049 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -173,24 +173,27 @@ export default class AppStore extends Store { @action _launchOnStartup({ enable, openInBackground }) { this.autoLaunchOnStart = enable; - const settings = { + let settings = { openAtLogin: enable, - openAsHidden: openInBackground, - path: updateExe, - args: [ - '--processStart', `"${exeName}"`, - ], }; // For Windows - if (openInBackground) { - settings.args.push( - '--process-start-args', '"--hidden"', - ); + if (process.platform === 'win32') { + settings = Object.assign({ + openAsHidden: openInBackground, + path: updateExe, + args: [ + '--processStart', `"${exeName}"`, + ], + }, settings); + + if (openInBackground) { + settings.args.push( + '--process-start-args', '"--hidden"', + ); + } } - app.setLoginItemSettings(settings); - gaEvent('App', enable ? 'enable autostart' : 'disable autostart'); } -- cgit v1.2.3-70-g09d2 From 05ce37fdf006819835d6751f6c6aedaff3d6beb3 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Mon, 23 Oct 2017 16:35:44 +0200 Subject: Add missing windows commit --- src/stores/AppStore.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 28fe14049..357ae7aed 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -16,10 +16,6 @@ import Miner from '../lib/Miner'; const { app, getCurrentWindow, powerMonitor } = remote; const defaultLocale = 'en-US'; -const appFolder = path.dirname(process.execPath); -const updateExe = path.resolve(appFolder, '..', 'Update.exe'); -const exeName = path.basename(process.execPath); - export default class AppStore extends Store { updateStatusTypes = { CHECKING: 'CHECKING', @@ -181,9 +177,9 @@ export default class AppStore extends Store { if (process.platform === 'win32') { settings = Object.assign({ openAsHidden: openInBackground, - path: updateExe, + path: app.getPath('exe'), args: [ - '--processStart', `"${exeName}"`, + '--processStart', `"${path.basename(app.getPath('exe'))}"`, ], }, settings); @@ -316,7 +312,7 @@ export default class AppStore extends Store { _checkAutoStart() { const loginItem = app.getLoginItemSettings({ - path: updateExe, + path: app.getPath('exe'), }); this.autoLaunchOnStart = loginItem.openAtLogin; -- cgit v1.2.3-70-g09d2