diff options
author | Danny Qiu <dqiu55@gmail.com> | 2017-12-29 01:33:42 -0500 |
---|---|---|
committer | Danny Qiu <dqiu55@gmail.com> | 2017-12-29 01:33:46 -0500 |
commit | 33c6e0af4112a927027a2533dea4bea3750e7865 (patch) | |
tree | fabd8a62049a187c70063e14d5171fa65dc1d159 /src/stores | |
parent | Delete session partition with service (diff) | |
download | ferdium-app-33c6e0af4112a927027a2533dea4bea3750e7865.tar.gz ferdium-app-33c6e0af4112a927027a2533dea4bea3750e7865.tar.zst ferdium-app-33c6e0af4112a927027a2533dea4bea3750e7865.zip |
Add button to clear global cache and all services
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/AppStore.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 5a6c12ee1..1136629ba 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -14,6 +14,8 @@ import locales from '../i18n/translations'; | |||
14 | import { gaEvent } from '../lib/analytics'; | 14 | import { gaEvent } from '../lib/analytics'; |
15 | import Miner from '../lib/Miner'; | 15 | import Miner from '../lib/Miner'; |
16 | 16 | ||
17 | import { getServiceIdsFromPartitions } from '../helpers/service-helpers.js'; | ||
18 | |||
17 | const { app, powerMonitor } = remote; | 19 | const { app, powerMonitor } = remote; |
18 | const defaultLocale = DEFAULT_APP_SETTINGS.locale; | 20 | const defaultLocale = DEFAULT_APP_SETTINGS.locale; |
19 | const autoLauncher = new AutoLaunch({ | 21 | const autoLauncher = new AutoLaunch({ |
@@ -30,6 +32,7 @@ export default class AppStore extends Store { | |||
30 | }; | 32 | }; |
31 | 33 | ||
32 | @observable healthCheckRequest = new Request(this.api.app, 'health'); | 34 | @observable healthCheckRequest = new Request(this.api.app, 'health'); |
35 | @observable clearAppCacheRequest = new Request(this.api.local, 'clearAppCache'); | ||
33 | 36 | ||
34 | @observable autoLaunchOnStart = true; | 37 | @observable autoLaunchOnStart = true; |
35 | 38 | ||
@@ -47,6 +50,8 @@ export default class AppStore extends Store { | |||
47 | 50 | ||
48 | @observable isSystemMuteOverridden = false; | 51 | @observable isSystemMuteOverridden = false; |
49 | 52 | ||
53 | @observable isClearingAllCache = false; | ||
54 | |||
50 | constructor(...args) { | 55 | constructor(...args) { |
51 | super(...args); | 56 | super(...args); |
52 | 57 | ||
@@ -61,6 +66,7 @@ export default class AppStore extends Store { | |||
61 | this.actions.app.healthCheck.listen(this._healthCheck.bind(this)); | 66 | this.actions.app.healthCheck.listen(this._healthCheck.bind(this)); |
62 | this.actions.app.muteApp.listen(this._muteApp.bind(this)); | 67 | this.actions.app.muteApp.listen(this._muteApp.bind(this)); |
63 | this.actions.app.toggleMuteApp.listen(this._toggleMuteApp.bind(this)); | 68 | this.actions.app.toggleMuteApp.listen(this._toggleMuteApp.bind(this)); |
69 | this.actions.app.clearAllCache.listen(this._clearAllCache.bind(this)); | ||
64 | 70 | ||
65 | this.registerReactions([ | 71 | this.registerReactions([ |
66 | this._offlineCheck.bind(this), | 72 | this._offlineCheck.bind(this), |
@@ -247,6 +253,15 @@ export default class AppStore extends Store { | |||
247 | this._muteApp({ isMuted: !this.stores.settings.all.isAppMuted }); | 253 | this._muteApp({ isMuted: !this.stores.settings.all.isAppMuted }); |
248 | } | 254 | } |
249 | 255 | ||
256 | @action async _clearAllCache() { | ||
257 | this.isClearingAllCache = true; | ||
258 | const clearAppCache = this.clearAppCacheRequest.execute(); | ||
259 | const serviceIds = await getServiceIdsFromPartitions(); | ||
260 | await Promise.all(serviceIds.map(id => this.actions.service.clearCache({ serviceId: id, }))); | ||
261 | await clearAppCache._promise; | ||
262 | this.isClearingAllCache = false; | ||
263 | } | ||
264 | |||
250 | // Reactions | 265 | // Reactions |
251 | _offlineCheck() { | 266 | _offlineCheck() { |
252 | if (!this.isOnline) { | 267 | if (!this.isOnline) { |