aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/AppStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r--src/stores/AppStore.js53
1 files changed, 35 insertions, 18 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index a5e0839f2..7dbef985d 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',
@@ -84,7 +80,7 @@ export default class AppStore extends Store {
84 // Check for updates once every 4 hours 80 // Check for updates once every 4 hours
85 setInterval(() => this._checkForUpdates(), CHECK_INTERVAL); 81 setInterval(() => this._checkForUpdates(), CHECK_INTERVAL);
86 // Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues) 82 // Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues)
87 setTimeout(() => this._checkForUpdates(), 3000); 83 setTimeout(() => this._checkForUpdates(), 30000);
88 ipcRenderer.on('autoUpdate', (event, data) => { 84 ipcRenderer.on('autoUpdate', (event, data) => {
89 if (data.available) { 85 if (data.available) {
90 this.updateStatus = this.updateStatusTypes.AVAILABLE; 86 this.updateStatus = this.updateStatusTypes.AVAILABLE;
@@ -125,6 +121,18 @@ export default class AppStore extends Store {
125 this.actions.service.openDevToolsForActiveService(); 121 this.actions.service.openDevToolsForActiveService();
126 }); 122 });
127 123
124 // Set active the next service
125 key(
126 '⌘+pagedown, ctrl+pagedown, ⌘+shift+tab, ctrl+shift+tab', () => {
127 this.actions.service.setActiveNext();
128 });
129
130 // Set active the prev service
131 key(
132 '⌘+pageup, ctrl+pageup, ⌘+tab, ctrl+tab', () => {
133 this.actions.service.setActivePrev();
134 });
135
128 this.locale = this._getDefaultLocale(); 136 this.locale = this._getDefaultLocale();
129 137
130 this._healthCheck(); 138 this._healthCheck();
@@ -161,24 +169,27 @@ export default class AppStore extends Store {
161 @action _launchOnStartup({ enable, openInBackground }) { 169 @action _launchOnStartup({ enable, openInBackground }) {
162 this.autoLaunchOnStart = enable; 170 this.autoLaunchOnStart = enable;
163 171
164 const settings = { 172 let settings = {
165 openAtLogin: enable, 173 openAtLogin: enable,
166 openAsHidden: openInBackground,
167 path: updateExe,
168 args: [
169 '--processStart', `"${exeName}"`,
170 ],
171 }; 174 };
172 175
173 // For Windows 176 // For Windows
174 if (openInBackground) { 177 if (process.platform === 'win32') {
175 settings.args.push( 178 settings = Object.assign({
176 '--process-start-args', '"--hidden"', 179 openAsHidden: openInBackground,
177 ); 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 }
178 } 191 }
179 192
180 app.setLoginItemSettings(settings);
181
182 gaEvent('App', enable ? 'enable autostart' : 'disable autostart'); 193 gaEvent('App', enable ? 'enable autostart' : 'disable autostart');
183 } 194 }
184 195
@@ -291,6 +302,12 @@ export default class AppStore extends Store {
291 // we need to wait until the settings request is resolved 302 // we need to wait until the settings request is resolved
292 await this.stores.settings.allSettingsRequest; 303 await this.stores.settings.allSettingsRequest;
293 304
305 // We don't set autostart on first launch for macOS as disabling
306 // the option is currently broken
307 // https://github.com/meetfranz/franz/issues/17
308 // https://github.com/electron/electron/issues/10880
309 if (process.platform === 'darwin') return;
310
294 if (!this.stores.settings.all.appStarts) { 311 if (!this.stores.settings.all.appStarts) {
295 this.actions.app.launchOnStartup({ 312 this.actions.app.launchOnStartup({
296 enable: true, 313 enable: true,
@@ -301,7 +318,7 @@ export default class AppStore extends Store {
301 318
302 _checkAutoStart() { 319 _checkAutoStart() {
303 const loginItem = app.getLoginItemSettings({ 320 const loginItem = app.getLoginItemSettings({
304 path: updateExe, 321 path: app.getPath('exe'),
305 }); 322 });
306 323
307 this.autoLaunchOnStart = loginItem.openAtLogin; 324 this.autoLaunchOnStart = loginItem.openAtLogin;