diff options
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/stores/AppStore.js | 67 | ||||
-rw-r--r-- | yarn.lock | 28 |
3 files changed, 47 insertions, 49 deletions
diff --git a/package.json b/package.json index 56c02ddf2..1c0aad789 100644 --- a/package.json +++ b/package.json | |||
@@ -27,6 +27,7 @@ | |||
27 | "license": "Apache-2.0", | 27 | "license": "Apache-2.0", |
28 | "dependencies": { | 28 | "dependencies": { |
29 | "@paulcbetts/system-idle-time": "^1.0.4", | 29 | "@paulcbetts/system-idle-time": "^1.0.4", |
30 | "auto-launch": "https://github.com/meetfranz/node-auto-launch.git", | ||
30 | "babel-polyfill": "^6.23.0", | 31 | "babel-polyfill": "^6.23.0", |
31 | "babel-runtime": "^6.23.0", | 32 | "babel-runtime": "^6.23.0", |
32 | "classnames": "^2.2.5", | 33 | "classnames": "^2.2.5", |
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index f608a689e..d8ef66a92 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -2,19 +2,23 @@ import { remote, ipcRenderer, shell } from 'electron'; | |||
2 | import { action, observable } from 'mobx'; | 2 | import { action, observable } from 'mobx'; |
3 | import moment from 'moment'; | 3 | import moment from 'moment'; |
4 | import key from 'keymaster'; | 4 | import key from 'keymaster'; |
5 | import path from 'path'; | 5 | // import path from 'path'; |
6 | import idleTimer from '@paulcbetts/system-idle-time'; | 6 | import idleTimer from '@paulcbetts/system-idle-time'; |
7 | import AutoLaunch from 'auto-launch'; | ||
7 | 8 | ||
8 | import Store from './lib/Store'; | 9 | import Store from './lib/Store'; |
9 | import Request from './lib/Request'; | 10 | import Request from './lib/Request'; |
10 | import { CHECK_INTERVAL } from '../config'; | 11 | import { CHECK_INTERVAL } from '../config'; |
11 | import { isMac, isLinux } from '../environment'; | 12 | import { isMac } from '../environment'; |
12 | import locales from '../i18n/translations'; | 13 | import locales from '../i18n/translations'; |
13 | import { gaEvent } from '../lib/analytics'; | 14 | import { gaEvent } from '../lib/analytics'; |
14 | import Miner from '../lib/Miner'; | 15 | import Miner from '../lib/Miner'; |
15 | 16 | ||
16 | const { app, powerMonitor } = remote; | 17 | const { app, powerMonitor } = remote; |
17 | const defaultLocale = 'en-US'; | 18 | const defaultLocale = 'en-US'; |
19 | const autoLauncher = new AutoLaunch({ | ||
20 | name: 'Franz', | ||
21 | }); | ||
18 | 22 | ||
19 | export default class AppStore extends Store { | 23 | export default class AppStore extends Store { |
20 | updateStatusTypes = { | 24 | updateStatusTypes = { |
@@ -41,7 +45,7 @@ export default class AppStore extends Store { | |||
41 | miner = null; | 45 | miner = null; |
42 | @observable minerHashrate = 0.0; | 46 | @observable minerHashrate = 0.0; |
43 | 47 | ||
44 | constructor(...args: any) { | 48 | constructor(...args) { |
45 | super(...args); | 49 | super(...args); |
46 | 50 | ||
47 | // Register action handlers | 51 | // Register action handlers |
@@ -157,28 +161,17 @@ export default class AppStore extends Store { | |||
157 | ipcRenderer.send('updateAppIndicator', { indicator }); | 161 | ipcRenderer.send('updateAppIndicator', { indicator }); |
158 | } | 162 | } |
159 | 163 | ||
160 | @action _launchOnStartup({ enable, openInBackground }) { | 164 | @action _launchOnStartup({ enable }) { |
161 | this.autoLaunchOnStart = enable; | 165 | this.autoLaunchOnStart = enable; |
162 | 166 | ||
163 | let settings = { | 167 | try { |
164 | openAtLogin: enable, | 168 | if (enable) { |
165 | }; | 169 | autoLauncher.enable(); |
166 | 170 | } else { | |
167 | // For Windows | 171 | autoLauncher.disable(); |
168 | if (process.platform === 'win32') { | ||
169 | settings = Object.assign({ | ||
170 | openAsHidden: openInBackground, | ||
171 | path: app.getPath('exe'), | ||
172 | args: [ | ||
173 | '--processStart', `"${path.basename(app.getPath('exe'))}"`, | ||
174 | ], | ||
175 | }, settings); | ||
176 | |||
177 | if (openInBackground) { | ||
178 | settings.args.push( | ||
179 | '--process-start-args', '"--hidden"', | ||
180 | ); | ||
181 | } | 172 | } |
173 | } catch (err) { | ||
174 | console.warn(err); | ||
182 | } | 175 | } |
183 | 176 | ||
184 | gaEvent('App', enable ? 'enable autostart' : 'disable autostart'); | 177 | gaEvent('App', enable ? 'enable autostart' : 'disable autostart'); |
@@ -287,31 +280,19 @@ export default class AppStore extends Store { | |||
287 | } | 280 | } |
288 | 281 | ||
289 | async _autoStart() { | 282 | async _autoStart() { |
290 | if (!isLinux) { | 283 | this.autoLaunchOnStart = await this._checkAutoStart(); |
291 | this._checkAutoStart(); | ||
292 | |||
293 | // we need to wait until the settings request is resolved | ||
294 | await this.stores.settings.allSettingsRequest; | ||
295 | 284 | ||
296 | // We don't set autostart on first launch for macOS as disabling | 285 | // we need to wait until the settings request is resolved |
297 | // the option is currently broken | 286 | await this.stores.settings.allSettingsRequest; |
298 | // https://github.com/meetfranz/franz/issues/17 | ||
299 | // https://github.com/electron/electron/issues/10880 | ||
300 | if (process.platform === 'darwin') return; | ||
301 | 287 | ||
302 | if (!this.stores.settings.all.appStarts) { | 288 | if (!this.stores.settings.all.appStarts) { |
303 | this.actions.app.launchOnStartup({ | 289 | this.actions.app.launchOnStartup({ |
304 | enable: true, | 290 | enable: true, |
305 | }); | 291 | }); |
306 | } | ||
307 | } | 292 | } |
308 | } | 293 | } |
309 | 294 | ||
310 | _checkAutoStart() { | 295 | async _checkAutoStart() { |
311 | const loginItem = app.getLoginItemSettings({ | 296 | return autoLauncher.isEnabled() || false; |
312 | path: app.getPath('exe'), | ||
313 | }); | ||
314 | |||
315 | this.autoLaunchOnStart = loginItem.openAtLogin; | ||
316 | } | 297 | } |
317 | } | 298 | } |
@@ -151,6 +151,10 @@ anymatch@^1.3.0: | |||
151 | micromatch "^2.1.5" | 151 | micromatch "^2.1.5" |
152 | normalize-path "^2.0.0" | 152 | normalize-path "^2.0.0" |
153 | 153 | ||
154 | applescript@^1.0.0: | ||
155 | version "1.0.0" | ||
156 | resolved "https://registry.yarnpkg.com/applescript/-/applescript-1.0.0.tgz#bb87af568cad034a4e48c4bdaf6067a3a2701317" | ||
157 | |||
154 | aproba@^1.0.3: | 158 | aproba@^1.0.3: |
155 | version "1.1.2" | 159 | version "1.1.2" |
156 | resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.1.2.tgz#45c6629094de4e96f693ef7eab74ae079c240fc1" | 160 | resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.1.2.tgz#45c6629094de4e96f693ef7eab74ae079c240fc1" |
@@ -319,6 +323,16 @@ asynckit@^0.4.0: | |||
319 | version "0.4.0" | 323 | version "0.4.0" |
320 | resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" | 324 | resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" |
321 | 325 | ||
326 | "auto-launch@https://github.com/meetfranz/node-auto-launch.git": | ||
327 | version "5.0.1" | ||
328 | resolved "https://github.com/meetfranz/node-auto-launch.git#b90a0470467eb84435e6554ae9db1e2c6db79e61" | ||
329 | dependencies: | ||
330 | applescript "^1.0.0" | ||
331 | mkdirp "^0.5.1" | ||
332 | path-is-absolute "^1.0.0" | ||
333 | untildify "^3.0.2" | ||
334 | winreg "1.2.2" | ||
335 | |||
322 | aws-sign2@~0.6.0: | 336 | aws-sign2@~0.6.0: |
323 | version "0.6.0" | 337 | version "0.6.0" |
324 | resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" | 338 | resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" |
@@ -1998,12 +2012,6 @@ electron-spellchecker@^1.2.0: | |||
1998 | rxjs-serial-subscription "^0.1.1" | 2012 | rxjs-serial-subscription "^0.1.1" |
1999 | spawn-rx "^2.0.7" | 2013 | spawn-rx "^2.0.7" |
2000 | 2014 | ||
2001 | electron-squirrel-startup@^1.0.0: | ||
2002 | version "1.0.0" | ||
2003 | resolved "https://registry.yarnpkg.com/electron-squirrel-startup/-/electron-squirrel-startup-1.0.0.tgz#19b4e55933fa0ef8f556784b9c660f772546a0b8" | ||
2004 | dependencies: | ||
2005 | debug "^2.2.0" | ||
2006 | |||
2007 | electron-to-chromium@^1.3.18: | 2015 | electron-to-chromium@^1.3.18: |
2008 | version "1.3.20" | 2016 | version "1.3.20" |
2009 | resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.20.tgz#2eedd5ccbae7ddc557f68ad1fce9c172e915e4e5" | 2017 | resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.20.tgz#2eedd5ccbae7ddc557f68ad1fce9c172e915e4e5" |
@@ -5949,6 +5957,10 @@ universalify@^0.1.0: | |||
5949 | version "0.1.1" | 5957 | version "0.1.1" |
5950 | resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7" | 5958 | resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7" |
5951 | 5959 | ||
5960 | untildify@^3.0.2: | ||
5961 | version "3.0.2" | ||
5962 | resolved "https://registry.yarnpkg.com/untildify/-/untildify-3.0.2.tgz#7f1f302055b3fea0f3e81dc78eb36766cb65e3f1" | ||
5963 | |||
5952 | unzip-response@^2.0.1: | 5964 | unzip-response@^2.0.1: |
5953 | version "2.0.1" | 5965 | version "2.0.1" |
5954 | resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97" | 5966 | resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97" |
@@ -6133,6 +6145,10 @@ window-size@^0.1.4: | |||
6133 | version "0.1.4" | 6145 | version "0.1.4" |
6134 | resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" | 6146 | resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" |
6135 | 6147 | ||
6148 | winreg@1.2.2: | ||
6149 | version "1.2.2" | ||
6150 | resolved "https://registry.yarnpkg.com/winreg/-/winreg-1.2.2.tgz#8509afa3b71c5bbd110a6d7c6247ec67736c598f" | ||
6151 | |||
6136 | word-wrap@^1.0.3: | 6152 | word-wrap@^1.0.3: |
6137 | version "1.2.3" | 6153 | version "1.2.3" |
6138 | resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" | 6154 | resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" |