aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/AppStore.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-10-23 16:44:56 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-10-23 16:44:56 +0200
commit05b8afa7a6e04397ba09b430312f868800bd2656 (patch)
tree5123ecb513e9e1a05cdddd2ff424e463dc83ec8a /src/stores/AppStore.js
parentdisable auto-enable for auto start on macOS (diff)
parentAdd missing windows commit (diff)
downloadferdium-app-05b8afa7a6e04397ba09b430312f868800bd2656.tar.gz
ferdium-app-05b8afa7a6e04397ba09b430312f868800bd2656.tar.zst
ferdium-app-05b8afa7a6e04397ba09b430312f868800bd2656.zip
Merge branch 'feature/autostart' into develop
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r--src/stores/AppStore.js33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index 254e647f1..8435c9ab8 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -16,10 +16,6 @@ import Miner from '../lib/Miner';
16const { app, getCurrentWindow, powerMonitor } = remote; 16const { app, getCurrentWindow, powerMonitor } = remote;
17const defaultLocale = 'en-US'; 17const defaultLocale = 'en-US';
18 18
19const appFolder = path.dirname(process.execPath);
20const updateExe = path.resolve(appFolder, '..', 'Update.exe');
21const exeName = path.basename(process.execPath);
22
23export default class AppStore extends Store { 19export default class AppStore extends Store {
24 updateStatusTypes = { 20 updateStatusTypes = {
25 CHECKING: 'CHECKING', 21 CHECKING: 'CHECKING',
@@ -173,24 +169,27 @@ export default class AppStore extends Store {
173 @action _launchOnStartup({ enable, openInBackground }) { 169 @action _launchOnStartup({ enable, openInBackground }) {
174 this.autoLaunchOnStart = enable; 170 this.autoLaunchOnStart = enable;
175 171
176 const settings = { 172 let settings = {
177 openAtLogin: enable, 173 openAtLogin: enable,
178 openAsHidden: openInBackground,
179 path: updateExe,
180 args: [
181 '--processStart', `"${exeName}"`,
182 ],
183 }; 174 };
184 175
185 // For Windows 176 // For Windows
186 if (openInBackground) { 177 if (process.platform === 'win32') {
187 settings.args.push( 178 settings = Object.assign({
188 '--process-start-args', '"--hidden"', 179 openAsHidden: openInBackground,
189 ); 180 path: app.getPath('exe'),
181 args: [
182 '--processStart', `"${path.basename(app.getPath('exe'))}"`,
183 ],
184 }, settings);
185
186 if (openInBackground) {
187 settings.args.push(
188 '--process-start-args', '"--hidden"',
189 );
190 }
190 } 191 }
191 192
192 app.setLoginItemSettings(settings);
193
194 gaEvent('App', enable ? 'enable autostart' : 'disable autostart'); 193 gaEvent('App', enable ? 'enable autostart' : 'disable autostart');
195 } 194 }
196 195
@@ -319,7 +318,7 @@ export default class AppStore extends Store {
319 318
320 _checkAutoStart() { 319 _checkAutoStart() {
321 const loginItem = app.getLoginItemSettings({ 320 const loginItem = app.getLoginItemSettings({
322 path: updateExe, 321 path: app.getPath('exe'),
323 }); 322 });
324 323
325 this.autoLaunchOnStart = loginItem.openAtLogin; 324 this.autoLaunchOnStart = loginItem.openAtLogin;