aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-12-24 21:40:49 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-12-24 21:40:49 +0100
commit531531e182b59dd4dab23d3f68717d609cdb7dd4 (patch)
tree2f6f09d9d10261528f51c5eac2c1a95b4e8b2864
parentMerge pull request #494 from heavypackets/websecurity-enable-patch (diff)
downloadferdium-app-531531e182b59dd4dab23d3f68717d609cdb7dd4.tar.gz
ferdium-app-531531e182b59dd4dab23d3f68717d609cdb7dd4.tar.zst
ferdium-app-531531e182b59dd4dab23d3f68717d609cdb7dd4.zip
fix(App): Fix service reload after waking machine up
-rw-r--r--src/stores/AppStore.js26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index 5a6c12ee1..7e2be5e9f 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -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 return setTimeout(() => this._reactivateServices(retryCount + 1), 5000);
372 }
373
374 console.debug('reactivateServices: reload all services');
375 this.actions.service.reloadAll();
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) {