diff options
author | 2017-10-23 16:44:56 +0200 | |
---|---|---|
committer | 2017-10-23 16:44:56 +0200 | |
commit | 05b8afa7a6e04397ba09b430312f868800bd2656 (patch) | |
tree | 5123ecb513e9e1a05cdddd2ff424e463dc83ec8a /src/stores | |
parent | disable auto-enable for auto start on macOS (diff) | |
parent | Add missing windows commit (diff) | |
download | ferdium-app-05b8afa7a6e04397ba09b430312f868800bd2656.tar.gz ferdium-app-05b8afa7a6e04397ba09b430312f868800bd2656.tar.zst ferdium-app-05b8afa7a6e04397ba09b430312f868800bd2656.zip |
Merge branch 'feature/autostart' into develop
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/AppStore.js | 33 |
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'; | |||
16 | const { app, getCurrentWindow, powerMonitor } = remote; | 16 | const { app, getCurrentWindow, powerMonitor } = remote; |
17 | const defaultLocale = 'en-US'; | 17 | const defaultLocale = 'en-US'; |
18 | 18 | ||
19 | const appFolder = path.dirname(process.execPath); | ||
20 | const updateExe = path.resolve(appFolder, '..', 'Update.exe'); | ||
21 | const exeName = path.basename(process.execPath); | ||
22 | |||
23 | export default class AppStore extends Store { | 19 | export 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; |