Permalink
Browse files

fix(App): Fix service reload after waking machine up

  • Loading branch information...
adlk committed Dec 24, 2017
1 parent b0ac4fc commit 531531e182b59dd4dab23d3f68717d609cdb7dd4
Showing with 22 additions and 4 deletions.
  1. +22 −4 src/stores/AppStore.js
@@ -124,15 +124,23 @@ export default class AppStore extends Store {
this.stores.router.push(data.url);
});
const TIMEOUT = 5000;
// Check system idle time every minute
setInterval(() => {
this.idleTime = idleTimer.getIdleTime();
}, 60000);
}, TIMEOUT);
// Reload all services after a healthy nap
powerMonitor.on('resume', () => {
setTimeout(window.location.reload, 5000);
});
// Alternative solution for powerMonitor as the resume event is not fired
// More information: https://github.com/electron/electron/issues/1615
let lastTime = (new Date()).getTime();
setInterval(() => {
const currentTime = (new Date()).getTime();
if (currentTime > (lastTime + TIMEOUT + 2000)) {
this._reactivateServices();
}
lastTime = currentTime;
}, TIMEOUT);
// Set active the next service
key(
@@ -357,6 +365,16 @@ export default class AppStore extends Store {
return autoLauncher.isEnabled() || false;
}
_reactivateServices(retryCount = 0) {
if (!this.isOnline) {
console.debug('reactivateServices: computer is offline, trying again in 5s, retries:', retryCount)
return setTimeout(() => this._reactivateServices(retryCount + 1), 5000);
}
console.debug('reactivateServices: reload all services');
this.actions.service.reloadAll();
}
_systemDND() {
const dnd = getDoNotDisturb();
if (dnd === this.stores.settings.all.isAppMuted || !this.isSystemMuteOverriden) {

0 comments on commit 531531e

Please sign in to comment.