aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-01-02 23:02:28 +0100
committerLibravatar GitHub <noreply@github.com>2018-01-02 23:02:28 +0100
commit306c331a32dff3026ab31b2e9879971f8d21892f (patch)
treeae16f4d5813c8de290407bf23064df466e1a8f68 /src/stores
parentMerge pull request #502 from meetfranz/feature/reload-service-root (diff)
parentFix linting issues pt 2 (diff)
downloadferdium-app-306c331a32dff3026ab31b2e9879971f8d21892f.tar.gz
ferdium-app-306c331a32dff3026ab31b2e9879971f8d21892f.tar.zst
ferdium-app-306c331a32dff3026ab31b2e9879971f8d21892f.zip
Merge pull request #506 from meetfranz/feature/reactivate-franz
Fix service reload after waking machine up
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/AppStore.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index 5a6c12ee1..aa6e801ff 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -14,7 +14,7 @@ import locales from '../i18n/translations';
14import { gaEvent } from '../lib/analytics'; 14import { gaEvent } from '../lib/analytics';
15import Miner from '../lib/Miner'; 15import Miner from '../lib/Miner';
16 16
17const { app, powerMonitor } = remote; 17const { app } = remote;
18const defaultLocale = DEFAULT_APP_SETTINGS.locale; 18const defaultLocale = DEFAULT_APP_SETTINGS.locale;
19const autoLauncher = new AutoLaunch({ 19const autoLauncher = new AutoLaunch({
20 name: 'Franz', 20 name: 'Franz',
@@ -124,15 +124,23 @@ export default class AppStore extends Store {
124 this.stores.router.push(data.url); 124 this.stores.router.push(data.url);
125 }); 125 });
126 126
127 const TIMEOUT = 5000;
127 // Check system idle time every minute 128 // Check system idle time every minute
128 setInterval(() => { 129 setInterval(() => {
129 this.idleTime = idleTimer.getIdleTime(); 130 this.idleTime = idleTimer.getIdleTime();
130 }, 60000); 131 }, TIMEOUT);
131 132
132 // Reload all services after a healthy nap 133 // Reload all services after a healthy nap
133 powerMonitor.on('resume', () => { 134 // Alternative solution for powerMonitor as the resume event is not fired
134 setTimeout(window.location.reload, 5000); 135 // More information: https://github.com/electron/electron/issues/1615
135 }); 136 let lastTime = (new Date()).getTime();
137 setInterval(() => {
138 const currentTime = (new Date()).getTime();
139 if (currentTime > (lastTime + TIMEOUT + 2000)) {
140 this._reactivateServices();
141 }
142 lastTime = currentTime;
143 }, TIMEOUT);
136 144
137 // Set active the next service 145 // Set active the next service
138 key( 146 key(
@@ -357,6 +365,16 @@ export default class AppStore extends Store {
357 return autoLauncher.isEnabled() || false; 365 return autoLauncher.isEnabled() || false;
358 } 366 }
359 367
368 _reactivateServices(retryCount = 0) {
369 if (!this.isOnline) {
370 console.debug('reactivateServices: computer is offline, trying again in 5s, retries:', retryCount);
371 setTimeout(() => this._reactivateServices(retryCount + 1), 5000);
372 } else {
373 console.debug('reactivateServices: reload all services');
374 this.actions.service.reloadAll();
375 }
376 }
377
360 _systemDND() { 378 _systemDND() {
361 const dnd = getDoNotDisturb(); 379 const dnd = getDoNotDisturb();
362 if (dnd === this.stores.settings.all.isAppMuted || !this.isSystemMuteOverriden) { 380 if (dnd === this.stores.settings.all.isAppMuted || !this.isSystemMuteOverriden) {