aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/AppStore.js53
-rw-r--r--src/stores/RecipesStore.js4
-rw-r--r--src/stores/ServicesStore.js24
-rw-r--r--src/stores/UserStore.js9
4 files changed, 72 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;
diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js
index cdc274685..67fee1d50 100644
--- a/src/stores/RecipesStore.js
+++ b/src/stores/RecipesStore.js
@@ -65,6 +65,10 @@ export default class RecipesStore extends Store {
65 @action async _update() { 65 @action async _update() {
66 const recipeIds = this.recipeIdForServices; 66 const recipeIds = this.recipeIdForServices;
67 const recipes = {}; 67 const recipes = {};
68
69 // Hackfix, reference this.all to fetch services
70 console.debug(`Check Recipe updates for ${this.all.map(recipe => recipe.id)}`);
71
68 recipeIds.forEach((r) => { 72 recipeIds.forEach((r) => {
69 const recipe = this.one(r); 73 const recipe = this.one(r);
70 recipes[r] = recipe.version; 74 recipes[r] = recipe.version;
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 77d2e7da4..19db05494 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -24,6 +24,8 @@ export default class ServicesStore extends Store {
24 24
25 // Register action handlers 25 // Register action handlers
26 this.actions.service.setActive.listen(this._setActive.bind(this)); 26 this.actions.service.setActive.listen(this._setActive.bind(this));
27 this.actions.service.setActiveNext.listen(this._setActiveNext.bind(this));
28 this.actions.service.setActivePrev.listen(this._setActivePrev.bind(this));
27 this.actions.service.showAddServiceInterface.listen(this._showAddServiceInterface.bind(this)); 29 this.actions.service.showAddServiceInterface.listen(this._showAddServiceInterface.bind(this));
28 this.actions.service.createService.listen(this._createService.bind(this)); 30 this.actions.service.createService.listen(this._createService.bind(this));
29 this.actions.service.createFromLegacyService.listen(this._createFromLegacyService.bind(this)); 31 this.actions.service.createFromLegacyService.listen(this._createFromLegacyService.bind(this));
@@ -206,6 +208,24 @@ export default class ServicesStore extends Store {
206 service.isActive = true; 208 service.isActive = true;
207 } 209 }
208 210
211 @action _setActiveNext() {
212 const nextIndex = this._wrapIndex(this.enabled.findIndex(service => service.isActive), 1, this.enabled.length);
213
214 this.all.forEach((s, index) => {
215 this.all[index].isActive = false;
216 });
217 this.enabled[nextIndex].isActive = true;
218 }
219
220 @action _setActivePrev() {
221 const prevIndex = this._wrapIndex(this.enabled.findIndex(service => service.isActive), -1, this.enabled.length);
222
223 this.all.forEach((s, index) => {
224 this.all[index].isActive = false;
225 });
226 this.enabled[prevIndex].isActive = true;
227 }
228
209 @action _setUnreadMessageCount({ serviceId, count }) { 229 @action _setUnreadMessageCount({ serviceId, count }) {
210 const service = this.one(serviceId); 230 const service = this.one(serviceId);
211 231
@@ -500,4 +520,8 @@ export default class ServicesStore extends Store {
500 _reorderAnalytics = debounce(() => { 520 _reorderAnalytics = debounce(() => {
501 gaEvent('Service', 'order'); 521 gaEvent('Service', 'order');
502 }, 5000); 522 }, 5000);
523
524 _wrapIndex(index, delta, size) {
525 return (((index + delta) % size) + size) % size;
526 }
503} 527}
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js
index 4927d615f..1cb2ecac3 100644
--- a/src/stores/UserStore.js
+++ b/src/stores/UserStore.js
@@ -192,6 +192,15 @@ export default class UserStore extends Store {
192 @action async _importLegacyServices({ services }) { 192 @action async _importLegacyServices({ services }) {
193 this.isImportLegacyServicesExecuting = true; 193 this.isImportLegacyServicesExecuting = true;
194 194
195 // Reduces recipe duplicates
196 const recipes = services.filter((obj, pos, arr) => arr.map(mapObj => mapObj.recipe.id).indexOf(obj.recipe.id) === pos).map(s => s.recipe.id);
197
198 // Install recipes
199 for (const recipe of recipes) {
200 // eslint-disable-next-line
201 await this.stores.recipes._install({ recipeId: recipe });
202 }
203
195 for (const service of services) { 204 for (const service of services) {
196 this.actions.service.createFromLegacyService({ 205 this.actions.service.createFromLegacyService({
197 data: service, 206 data: service,