diff options
author | Stefan Malzner <stefan@adlk.io> | 2018-01-04 09:56:12 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2018-01-04 09:56:12 +0100 |
commit | aa7cb9c84979adb58b4d6179467e6353cfb51d02 (patch) | |
tree | 6322d2207545464064e24f6bdd2f9724d1e4b813 /src/stores | |
parent | Replace cache string with localized string (diff) | |
parent | Merge branch 'develop' into service-cache-cleanup (diff) | |
download | ferdium-app-aa7cb9c84979adb58b4d6179467e6353cfb51d02.tar.gz ferdium-app-aa7cb9c84979adb58b4d6179467e6353cfb51d02.tar.zst ferdium-app-aa7cb9c84979adb58b4d6179467e6353cfb51d02.zip |
Merge branch 'service-cache-cleanup' of https://github.com/dannyqiu/franz into feature/service-cache-cleanup
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/AppStore.js | 29 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 5 |
2 files changed, 27 insertions, 7 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) { |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 237264bcc..87ee57a0d 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -377,7 +377,7 @@ export default class ServicesStore extends Store { | |||
377 | const service = this.one(serviceId); | 377 | const service = this.one(serviceId); |
378 | service.resetMessageCount(); | 378 | service.resetMessageCount(); |
379 | 379 | ||
380 | service.webview.reload(); | 380 | service.webview.loadURL(service.url); |
381 | } | 381 | } |
382 | 382 | ||
383 | @action _reloadActive() { | 383 | @action _reloadActive() { |
@@ -506,12 +506,13 @@ export default class ServicesStore extends Store { | |||
506 | .reduce((a, b) => a + b, 0); | 506 | .reduce((a, b) => a + b, 0); |
507 | 507 | ||
508 | const unreadIndirectMessageCount = this.allDisplayed | 508 | const unreadIndirectMessageCount = this.allDisplayed |
509 | .filter(s => (showMessageBadgeWhenMuted || s.isIndirectMessageBadgeEnabled) && showMessageBadgesEvenWhenMuted && s.isBadgeEnabled) | 509 | .filter(s => (showMessageBadgeWhenMuted && showMessageBadgesEvenWhenMuted) && (s.isBadgeEnabled && s.isIndirectMessageBadgeEnabled)) |
510 | .map(s => s.unreadIndirectMessageCount) | 510 | .map(s => s.unreadIndirectMessageCount) |
511 | .reduce((a, b) => a + b, 0); | 511 | .reduce((a, b) => a + b, 0); |
512 | 512 | ||
513 | // We can't just block this earlier, otherwise the mobx reaction won't be aware of the vars to watch in some cases | 513 | // We can't just block this earlier, otherwise the mobx reaction won't be aware of the vars to watch in some cases |
514 | if (showMessageBadgesEvenWhenMuted) { | 514 | if (showMessageBadgesEvenWhenMuted) { |
515 | console.log('set badge', unreadDirectMessageCount, unreadIndirectMessageCount); | ||
515 | this.actions.app.setBadge({ | 516 | this.actions.app.setBadge({ |
516 | unreadDirectMessageCount, | 517 | unreadDirectMessageCount, |
517 | unreadIndirectMessageCount, | 518 | unreadIndirectMessageCount, |