diff options
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r-- | src/stores/AppStore.js | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 63130a3ba..e33f50f05 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -17,7 +17,8 @@ import Miner from '../lib/Miner'; | |||
17 | 17 | ||
18 | import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; | 18 | import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; |
19 | 19 | ||
20 | const { app, powerMonitor } = remote; | 20 | const { app } = remote; |
21 | |||
21 | const defaultLocale = DEFAULT_APP_SETTINGS.locale; | 22 | const defaultLocale = DEFAULT_APP_SETTINGS.locale; |
22 | const autoLauncher = new AutoLaunch({ | 23 | const autoLauncher = new AutoLaunch({ |
23 | name: 'Franz', | 24 | name: 'Franz', |
@@ -132,15 +133,23 @@ export default class AppStore extends Store { | |||
132 | this.stores.router.push(data.url); | 133 | this.stores.router.push(data.url); |
133 | }); | 134 | }); |
134 | 135 | ||
136 | const TIMEOUT = 5000; | ||
135 | // Check system idle time every minute | 137 | // Check system idle time every minute |
136 | setInterval(() => { | 138 | setInterval(() => { |
137 | this.idleTime = idleTimer.getIdleTime(); | 139 | this.idleTime = idleTimer.getIdleTime(); |
138 | }, 60000); | 140 | }, TIMEOUT); |
139 | 141 | ||
140 | // Reload all services after a healthy nap | 142 | // Reload all services after a healthy nap |
141 | powerMonitor.on('resume', () => { | 143 | // Alternative solution for powerMonitor as the resume event is not fired |
142 | setTimeout(window.location.reload, 5000); | 144 | // More information: https://github.com/electron/electron/issues/1615 |
143 | }); | 145 | let lastTime = (new Date()).getTime(); |
146 | setInterval(() => { | ||
147 | const currentTime = (new Date()).getTime(); | ||
148 | if (currentTime > (lastTime + TIMEOUT + 2000)) { | ||
149 | this._reactivateServices(); | ||
150 | } | ||
151 | lastTime = currentTime; | ||
152 | }, TIMEOUT); | ||
144 | 153 | ||
145 | // Set active the next service | 154 | // Set active the next service |
146 | key( | 155 | key( |
@@ -386,6 +395,16 @@ export default class AppStore extends Store { | |||
386 | return autoLauncher.isEnabled() || false; | 395 | return autoLauncher.isEnabled() || false; |
387 | } | 396 | } |
388 | 397 | ||
398 | _reactivateServices(retryCount = 0) { | ||
399 | if (!this.isOnline) { | ||
400 | console.debug('reactivateServices: computer is offline, trying again in 5s, retries:', retryCount); | ||
401 | setTimeout(() => this._reactivateServices(retryCount + 1), 5000); | ||
402 | } else { | ||
403 | console.debug('reactivateServices: reload all services'); | ||
404 | this.actions.service.reloadAll(); | ||
405 | } | ||
406 | } | ||
407 | |||
389 | _systemDND() { | 408 | _systemDND() { |
390 | const dnd = getDoNotDisturb(); | 409 | const dnd = getDoNotDisturb(); |
391 | if (dnd === this.stores.settings.all.isAppMuted || !this.isSystemMuteOverriden) { | 410 | if (dnd === this.stores.settings.all.isAppMuted || !this.isSystemMuteOverriden) { |