aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/AppStore.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-01-03 23:50:59 +0100
committerLibravatar GitHub <noreply@github.com>2018-01-03 23:50:59 +0100
commita74ce8d78d4db3f08bec5e0e3d6eb47fae763e40 (patch)
tree5c2738adaa132570ffa8f5173b9508e9eda87b06 /src/stores/AppStore.js
parentfeat(App): Add option to clear app cache (@dannyqiu) (diff)
parentMerge pull request #533 from meetfranz/feature/ux-service-search (diff)
downloadferdium-app-a74ce8d78d4db3f08bec5e0e3d6eb47fae763e40.tar.gz
ferdium-app-a74ce8d78d4db3f08bec5e0e3d6eb47fae763e40.tar.zst
ferdium-app-a74ce8d78d4db3f08bec5e0e3d6eb47fae763e40.zip
Merge branch 'develop' into service-cache-cleanup
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r--src/stores/AppStore.js29
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
18import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; 18import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js';
19 19
20const { app, powerMonitor } = remote; 20const { app } = remote;
21
21const defaultLocale = DEFAULT_APP_SETTINGS.locale; 22const defaultLocale = DEFAULT_APP_SETTINGS.locale;
22const autoLauncher = new AutoLaunch({ 23const 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) {