diff options
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | src/api/LocalApi.js | 4 | ||||
-rw-r--r-- | src/api/server/LocalApi.js | 24 | ||||
-rw-r--r-- | src/api/server/ServerApi.js | 4 | ||||
-rw-r--r-- | src/components/settings/services/EditServiceForm.js | 30 | ||||
-rw-r--r-- | src/components/settings/settings/EditSettingsForm.js | 51 | ||||
-rw-r--r-- | src/containers/settings/EditServiceScreen.js | 11 | ||||
-rw-r--r-- | src/containers/settings/EditSettingsScreen.js | 14 | ||||
-rw-r--r-- | src/helpers/service-helpers.js | 9 | ||||
-rw-r--r-- | src/i18n/locales/en-US.json | 6 | ||||
-rw-r--r-- | src/stores/AppStore.js | 22 | ||||
-rw-r--r-- | yarn.lock | 14 |
12 files changed, 109 insertions, 82 deletions
diff --git a/package.json b/package.json index 301b88b81..0a2bd8991 100644 --- a/package.json +++ b/package.json | |||
@@ -34,6 +34,7 @@ | |||
34 | "babel-polyfill": "^6.23.0", | 34 | "babel-polyfill": "^6.23.0", |
35 | "babel-runtime": "^6.23.0", | 35 | "babel-runtime": "^6.23.0", |
36 | "classnames": "^2.2.5", | 36 | "classnames": "^2.2.5", |
37 | "du": "^0.1.0", | ||
37 | "electron-fetch": "^1.1.0", | 38 | "electron-fetch": "^1.1.0", |
38 | "electron-spellchecker": "^1.1.2", | 39 | "electron-spellchecker": "^1.1.2", |
39 | "electron-updater": "^2.4.3", | 40 | "electron-updater": "^2.4.3", |
@@ -54,6 +55,7 @@ | |||
54 | "mobx-react-router": "^3.1.2", | 55 | "mobx-react-router": "^3.1.2", |
55 | "moment": "^2.17.1", | 56 | "moment": "^2.17.1", |
56 | "normalize-url": "^1.9.1", | 57 | "normalize-url": "^1.9.1", |
58 | "pretty-bytes": "^4.0.2", | ||
57 | "prop-types": "^15.5.10", | 59 | "prop-types": "^15.5.10", |
58 | "prop-types-extended": "^0.2.1", | 60 | "prop-types-extended": "^0.2.1", |
59 | "react": "^15.4.1", | 61 | "react": "^15.4.1", |
diff --git a/src/api/LocalApi.js b/src/api/LocalApi.js index d52e9cd10..3f84f8a0b 100644 --- a/src/api/LocalApi.js +++ b/src/api/LocalApi.js | |||
@@ -16,6 +16,10 @@ export default class LocalApi { | |||
16 | return this.local.removeKey(key); | 16 | return this.local.removeKey(key); |
17 | } | 17 | } |
18 | 18 | ||
19 | getAppCacheSize() { | ||
20 | return this.local.getAppCacheSize(); | ||
21 | } | ||
22 | |||
19 | clearAppCache() { | 23 | clearAppCache() { |
20 | return this.local.clearAppCache(); | 24 | return this.local.clearAppCache(); |
21 | } | 25 | } |
diff --git a/src/api/server/LocalApi.js b/src/api/server/LocalApi.js index d2ce0c9de..e95d750ac 100644 --- a/src/api/server/LocalApi.js +++ b/src/api/server/LocalApi.js | |||
@@ -1,4 +1,7 @@ | |||
1 | import { remote } from 'electron'; | 1 | import { remote } from 'electron'; |
2 | import du from 'du'; | ||
3 | |||
4 | import { getServicePartitionsDirectory } from '../../helpers/service-helpers.js'; | ||
2 | 5 | ||
3 | const { session } = remote; | 6 | const { session } = remote; |
4 | 7 | ||
@@ -36,14 +39,29 @@ export default class LocalApi { | |||
36 | } | 39 | } |
37 | 40 | ||
38 | // Services | 41 | // Services |
42 | async getAppCacheSize() { | ||
43 | const partitionsDir = getServicePartitionsDirectory(); | ||
44 | return new Promise((resolve, reject) => { | ||
45 | du(partitionsDir, (err, size) => { | ||
46 | if (err) reject(err); | ||
47 | |||
48 | console.debug('LocalApi::getAppCacheSize resolves', size); | ||
49 | resolve(size); | ||
50 | }); | ||
51 | }); | ||
52 | } | ||
53 | |||
39 | async clearCache(serviceId) { | 54 | async clearCache(serviceId) { |
40 | console.debug(`Clearing cache for persist:service-${serviceId}`); | ||
41 | const s = session.fromPartition(`persist:service-${serviceId}`); | 55 | const s = session.fromPartition(`persist:service-${serviceId}`); |
42 | await new Promise(resolve => s.clearCache(resolve)); | 56 | |
57 | console.debug('LocalApi::clearCache resolves', serviceId); | ||
58 | return new Promise(resolve => s.clearCache(resolve)); | ||
43 | } | 59 | } |
44 | 60 | ||
45 | async clearAppCache() { | 61 | async clearAppCache() { |
46 | const s = session.defaultSession; | 62 | const s = session.defaultSession; |
47 | await new Promise(resolve => s.clearCache(resolve)); | 63 | |
64 | console.debug('LocalApi::clearCache clearAppCache'); | ||
65 | return new Promise(resolve => s.clearCache(resolve)); | ||
48 | } | 66 | } |
49 | } | 67 | } |
diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js index 3daa2d8b6..d75d2e559 100644 --- a/src/api/server/ServerApi.js +++ b/src/api/server/ServerApi.js | |||
@@ -213,7 +213,9 @@ export default class ServerApi { | |||
213 | throw request; | 213 | throw request; |
214 | } | 214 | } |
215 | const data = await request.json(); | 215 | const data = await request.json(); |
216 | await removeServicePartitionDirectory(id); | 216 | |
217 | removeServicePartitionDirectory(id, true); | ||
218 | |||
217 | console.debug('ServerApi::deleteService resolves', data); | 219 | console.debug('ServerApi::deleteService resolves', data); |
218 | return data; | 220 | return data; |
219 | } | 221 | } |
diff --git a/src/components/settings/services/EditServiceForm.js b/src/components/settings/services/EditServiceForm.js index b5300f605..4458c4c5a 100644 --- a/src/components/settings/services/EditServiceForm.js +++ b/src/components/settings/services/EditServiceForm.js | |||
@@ -71,14 +71,6 @@ const messages = defineMessages({ | |||
71 | id: 'settings.service.form.isMutedInfo', | 71 | id: 'settings.service.form.isMutedInfo', |
72 | defaultMessage: '!!!When disabled, all notification sounds and audio playback are muted', | 72 | defaultMessage: '!!!When disabled, all notification sounds and audio playback are muted', |
73 | }, | 73 | }, |
74 | buttonClearCache: { | ||
75 | id: 'settings.service.form.buttonClearCache', | ||
76 | defaultMessage: '!!!Clear cache', | ||
77 | }, | ||
78 | buttonClearingCache: { | ||
79 | id: 'settings.service.form.buttonClearingCache', | ||
80 | defaultMessage: '!!!Clearing cache', | ||
81 | }, | ||
82 | headlineNotifications: { | 74 | headlineNotifications: { |
83 | id: 'settings.service.form.headlineNotifications', | 75 | id: 'settings.service.form.headlineNotifications', |
84 | defaultMessage: '!!!Notifications', | 76 | defaultMessage: '!!!Notifications', |
@@ -110,10 +102,8 @@ export default class EditServiceForm extends Component { | |||
110 | form: PropTypes.instanceOf(Form).isRequired, | 102 | form: PropTypes.instanceOf(Form).isRequired, |
111 | onSubmit: PropTypes.func.isRequired, | 103 | onSubmit: PropTypes.func.isRequired, |
112 | onDelete: PropTypes.func.isRequired, | 104 | onDelete: PropTypes.func.isRequired, |
113 | onClearCache: PropTypes.func.isRequired, | ||
114 | isSaving: PropTypes.bool.isRequired, | 105 | isSaving: PropTypes.bool.isRequired, |
115 | isDeleting: PropTypes.bool.isRequired, | 106 | isDeleting: PropTypes.bool.isRequired, |
116 | isClearingCache: PropTypes.bool.isRequired, | ||
117 | }; | 107 | }; |
118 | 108 | ||
119 | static defaultProps = { | 109 | static defaultProps = { |
@@ -168,9 +158,7 @@ export default class EditServiceForm extends Component { | |||
168 | form, | 158 | form, |
169 | isSaving, | 159 | isSaving, |
170 | isDeleting, | 160 | isDeleting, |
171 | isClearingCache, | ||
172 | onDelete, | 161 | onDelete, |
173 | onClearCache, | ||
174 | } = this.props; | 162 | } = this.props; |
175 | const { intl } = this.context; | 163 | const { intl } = this.context; |
176 | 164 | ||
@@ -193,23 +181,6 @@ export default class EditServiceForm extends Component { | |||
193 | /> | 181 | /> |
194 | ); | 182 | ); |
195 | 183 | ||
196 | const clearCacheButton = isClearingCache ? ( | ||
197 | <Button | ||
198 | buttonType="secondary" | ||
199 | className="settings__clear-cache-button" | ||
200 | loaded={false} | ||
201 | label={intl.formatMessage(messages.buttonClearingCache)} | ||
202 | disabled | ||
203 | /> | ||
204 | ) : ( | ||
205 | <Button | ||
206 | buttonType="warning" | ||
207 | className="settings__clear-cache-button" | ||
208 | label={intl.formatMessage(messages.buttonClearCache)} | ||
209 | onClick={onClearCache} | ||
210 | /> | ||
211 | ); | ||
212 | |||
213 | let activeTabIndex = 0; | 184 | let activeTabIndex = 0; |
214 | if (recipe.hasHostedOption && service.team) { | 185 | if (recipe.hasHostedOption && service.team) { |
215 | activeTabIndex = 1; | 186 | activeTabIndex = 1; |
@@ -316,7 +287,6 @@ export default class EditServiceForm extends Component { | |||
316 | <div className="settings__settings-group"> | 287 | <div className="settings__settings-group"> |
317 | <h3>{intl.formatMessage(messages.headlineGeneral)}</h3> | 288 | <h3>{intl.formatMessage(messages.headlineGeneral)}</h3> |
318 | <Toggle field={form.$('isEnabled')} /> | 289 | <Toggle field={form.$('isEnabled')} /> |
319 | {clearCacheButton} | ||
320 | </div> | 290 | </div> |
321 | </div> | 291 | </div> |
322 | {recipe.message && ( | 292 | {recipe.message && ( |
diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js index 074a4b731..4f027638c 100644 --- a/src/components/settings/settings/EditSettingsForm.js +++ b/src/components/settings/settings/EditSettingsForm.js | |||
@@ -40,13 +40,13 @@ const messages = defineMessages({ | |||
40 | id: 'settings.app.translationHelp', | 40 | id: 'settings.app.translationHelp', |
41 | defaultMessage: '!!!Help us to translate Franz into your language.', | 41 | defaultMessage: '!!!Help us to translate Franz into your language.', |
42 | }, | 42 | }, |
43 | cacheInfo: { | ||
44 | id: 'settings.app.cacheInfo', | ||
45 | defaultMessage: '!!!Franz cache is currently using {size} of disk space.', | ||
46 | }, | ||
43 | buttonClearAllCache: { | 47 | buttonClearAllCache: { |
44 | id: 'settings.app.buttonClearAllCache', | 48 | id: 'settings.app.buttonClearAllCache', |
45 | defaultMessage: '!!!Clear global cache for Franz and all services', | 49 | defaultMessage: '!!!Clear cache', |
46 | }, | ||
47 | buttonClearingAllCache: { | ||
48 | id: 'settings.app.buttonClearingAllCache', | ||
49 | defaultMessage: '!!!Clearing global cache...', | ||
50 | }, | 50 | }, |
51 | buttonSearchForUpdate: { | 51 | buttonSearchForUpdate: { |
52 | id: 'settings.app.buttonSearchForUpdate', | 52 | id: 'settings.app.buttonSearchForUpdate', |
@@ -87,6 +87,7 @@ export default class EditSettingsForm extends Component { | |||
87 | updateIsReadyToInstall: PropTypes.bool.isRequired, | 87 | updateIsReadyToInstall: PropTypes.bool.isRequired, |
88 | isClearingAllCache: PropTypes.bool.isRequired, | 88 | isClearingAllCache: PropTypes.bool.isRequired, |
89 | onClearAllCache: PropTypes.func.isRequired, | 89 | onClearAllCache: PropTypes.func.isRequired, |
90 | cacheSize: PropTypes.string.isRequired, | ||
90 | }; | 91 | }; |
91 | 92 | ||
92 | static contextTypes = { | 93 | static contextTypes = { |
@@ -115,6 +116,7 @@ export default class EditSettingsForm extends Component { | |||
115 | updateIsReadyToInstall, | 116 | updateIsReadyToInstall, |
116 | isClearingAllCache, | 117 | isClearingAllCache, |
117 | onClearAllCache, | 118 | onClearAllCache, |
119 | cacheSize, | ||
118 | } = this.props; | 120 | } = this.props; |
119 | const { intl } = this.context; | 121 | const { intl } = this.context; |
120 | 122 | ||
@@ -127,23 +129,6 @@ export default class EditSettingsForm extends Component { | |||
127 | updateButtonLabelMessage = messages.buttonSearchForUpdate; | 129 | updateButtonLabelMessage = messages.buttonSearchForUpdate; |
128 | } | 130 | } |
129 | 131 | ||
130 | const clearAllCacheButton = isClearingAllCache ? ( | ||
131 | <Button | ||
132 | buttonType="secondary" | ||
133 | className="settings__clear-all-cache-button" | ||
134 | loaded={false} | ||
135 | label={intl.formatMessage(messages.buttonClearingAllCache)} | ||
136 | disabled | ||
137 | /> | ||
138 | ) : ( | ||
139 | <Button | ||
140 | buttonType="warning" | ||
141 | className="settings__clear-all-cache-button" | ||
142 | label={intl.formatMessage(messages.buttonClearAllCache)} | ||
143 | onClick={onClearAllCache} | ||
144 | /> | ||
145 | ); | ||
146 | |||
147 | return ( | 132 | return ( |
148 | <div className="settings__main"> | 133 | <div className="settings__main"> |
149 | <div className="settings__header"> | 134 | <div className="settings__header"> |
@@ -184,7 +169,26 @@ export default class EditSettingsForm extends Component { | |||
184 | <h2 id="advanced">{intl.formatMessage(messages.headlineAdvanced)}</h2> | 169 | <h2 id="advanced">{intl.formatMessage(messages.headlineAdvanced)}</h2> |
185 | <Toggle field={form.$('enableSpellchecking')} /> | 170 | <Toggle field={form.$('enableSpellchecking')} /> |
186 | {/* <Select field={form.$('spellcheckingLanguage')} /> */} | 171 | {/* <Select field={form.$('spellcheckingLanguage')} /> */} |
187 | {clearAllCacheButton} | 172 | <div className="settings__settings-group"> |
173 | <h3> | ||
174 | {/* {intl.formatMessage(messages.headlineGeneral)} */} | ||
175 | Service cache | ||
176 | </h3> | ||
177 | <p> | ||
178 | {intl.formatMessage(messages.cacheInfo, { | ||
179 | size: cacheSize, | ||
180 | })} | ||
181 | </p> | ||
182 | <p> | ||
183 | <Button | ||
184 | buttonType="secondary" | ||
185 | label={intl.formatMessage(messages.buttonClearAllCache)} | ||
186 | onClick={onClearAllCache} | ||
187 | disabled={isClearingAllCache} | ||
188 | loaded={!isClearingAllCache} | ||
189 | /> | ||
190 | </p> | ||
191 | </div> | ||
188 | 192 | ||
189 | {/* Updates */} | 193 | {/* Updates */} |
190 | <h2 id="updates">{intl.formatMessage(messages.headlineUpdates)}</h2> | 194 | <h2 id="updates">{intl.formatMessage(messages.headlineUpdates)}</h2> |
@@ -195,6 +199,7 @@ export default class EditSettingsForm extends Component { | |||
195 | /> | 199 | /> |
196 | ) : ( | 200 | ) : ( |
197 | <Button | 201 | <Button |
202 | buttonType="secondary" | ||
198 | label={intl.formatMessage(updateButtonLabelMessage)} | 203 | label={intl.formatMessage(updateButtonLabelMessage)} |
199 | onClick={checkForUpdates} | 204 | onClick={checkForUpdates} |
200 | disabled={isCheckingForUpdates || isUpdateAvailable} | 205 | disabled={isCheckingForUpdates || isUpdateAvailable} |
diff --git a/src/containers/settings/EditServiceScreen.js b/src/containers/settings/EditServiceScreen.js index 78f043e80..3c52152b1 100644 --- a/src/containers/settings/EditServiceScreen.js +++ b/src/containers/settings/EditServiceScreen.js | |||
@@ -169,14 +169,6 @@ export default class EditServiceScreen extends Component { | |||
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | clearCache() { | ||
173 | const { clearCache } = this.props.actions.service; | ||
174 | const { activeSettings: service } = this.props.stores.services; | ||
175 | clearCache({ | ||
176 | serviceId: service.id, | ||
177 | }); | ||
178 | } | ||
179 | |||
180 | render() { | 172 | render() { |
181 | const { recipes, services, user } = this.props.stores; | 173 | const { recipes, services, user } = this.props.stores; |
182 | const { action } = this.props.router.params; | 174 | const { action } = this.props.router.params; |
@@ -219,10 +211,8 @@ export default class EditServiceScreen extends Component { | |||
219 | status={services.actionStatus} | 211 | status={services.actionStatus} |
220 | isSaving={services.updateServiceRequest.isExecuting || services.createServiceRequest.isExecuting} | 212 | isSaving={services.updateServiceRequest.isExecuting || services.createServiceRequest.isExecuting} |
221 | isDeleting={services.deleteServiceRequest.isExecuting} | 213 | isDeleting={services.deleteServiceRequest.isExecuting} |
222 | isClearingCache={services.clearCacheRequest.isExecuting} | ||
223 | onSubmit={d => this.onSubmit(d)} | 214 | onSubmit={d => this.onSubmit(d)} |
224 | onDelete={() => this.deleteService()} | 215 | onDelete={() => this.deleteService()} |
225 | onClearCache={() => this.clearCache()} | ||
226 | /> | 216 | /> |
227 | ); | 217 | ); |
228 | } | 218 | } |
@@ -244,7 +234,6 @@ EditServiceScreen.wrappedComponent.propTypes = { | |||
244 | createService: PropTypes.func.isRequired, | 234 | createService: PropTypes.func.isRequired, |
245 | updateService: PropTypes.func.isRequired, | 235 | updateService: PropTypes.func.isRequired, |
246 | deleteService: PropTypes.func.isRequired, | 236 | deleteService: PropTypes.func.isRequired, |
247 | clearCache: PropTypes.func.isRequired, | ||
248 | }).isRequired, | 237 | }).isRequired, |
249 | }).isRequired, | 238 | }).isRequired, |
250 | }; | 239 | }; |
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 890bf6501..9fa815a0a 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js | |||
@@ -193,8 +193,17 @@ export default class EditSettingsScreen extends Component { | |||
193 | } | 193 | } |
194 | 194 | ||
195 | render() { | 195 | render() { |
196 | const { updateStatus, updateStatusTypes, isClearingAllCache } = this.props.stores.app; | 196 | const { |
197 | const { checkForUpdates, installUpdate, clearAllCache } = this.props.actions.app; | 197 | updateStatus, |
198 | cacheSize, | ||
199 | updateStatusTypes, | ||
200 | isClearingAllCache, | ||
201 | } = this.props.stores.app; | ||
202 | const { | ||
203 | checkForUpdates, | ||
204 | installUpdate, | ||
205 | clearAllCache, | ||
206 | } = this.props.actions.app; | ||
198 | const form = this.prepareForm(); | 207 | const form = this.prepareForm(); |
199 | 208 | ||
200 | return ( | 209 | return ( |
@@ -207,6 +216,7 @@ export default class EditSettingsScreen extends Component { | |||
207 | noUpdateAvailable={updateStatus === updateStatusTypes.NOT_AVAILABLE} | 216 | noUpdateAvailable={updateStatus === updateStatusTypes.NOT_AVAILABLE} |
208 | updateIsReadyToInstall={updateStatus === updateStatusTypes.DOWNLOADED} | 217 | updateIsReadyToInstall={updateStatus === updateStatusTypes.DOWNLOADED} |
209 | onSubmit={d => this.onSubmit(d)} | 218 | onSubmit={d => this.onSubmit(d)} |
219 | cacheSize={cacheSize} | ||
210 | isClearingAllCache={isClearingAllCache} | 220 | isClearingAllCache={isClearingAllCache} |
211 | onClearAllCache={clearAllCache} | 221 | onClearAllCache={clearAllCache} |
212 | /> | 222 | /> |
diff --git a/src/helpers/service-helpers.js b/src/helpers/service-helpers.js index eb804103e..5f63f6b7c 100644 --- a/src/helpers/service-helpers.js +++ b/src/helpers/service-helpers.js | |||
@@ -4,16 +4,17 @@ import fs from 'fs-extra'; | |||
4 | 4 | ||
5 | const app = remote.app; | 5 | const app = remote.app; |
6 | 6 | ||
7 | function getServicePartitionsDirectory() { | 7 | export function getServicePartitionsDirectory() { |
8 | return path.join(app.getPath('userData'), 'Partitions'); | 8 | return path.join(app.getPath('userData'), 'Partitions'); |
9 | } | 9 | } |
10 | 10 | ||
11 | export function removeServicePartitionDirectory(id = '') { | 11 | export function removeServicePartitionDirectory(id = '', addServicePrefix = false) { |
12 | const servicePartition = path.join(getServicePartitionsDirectory(), `service-${id}`); | 12 | const servicePartition = path.join(getServicePartitionsDirectory(), `${addServicePrefix ? 'service-' : ''}${id}`); |
13 | |||
13 | return fs.remove(servicePartition); | 14 | return fs.remove(servicePartition); |
14 | } | 15 | } |
15 | 16 | ||
16 | export async function getServiceIdsFromPartitions() { | 17 | export async function getServiceIdsFromPartitions() { |
17 | const files = await fs.readdir(getServicePartitionsDirectory()); | 18 | const files = await fs.readdir(getServicePartitionsDirectory()); |
18 | return files.map(filename => filename.replace('service-', '')); | 19 | return files.filter(n => n !== '__chrome_extension'); |
19 | } | 20 | } |
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json index 665d0e3cd..b8a8151f1 100644 --- a/src/i18n/locales/en-US.json +++ b/src/i18n/locales/en-US.json | |||
@@ -124,8 +124,6 @@ | |||
124 | "settings.service.form.indirectMessages": "Show message badge for all new messages", | 124 | "settings.service.form.indirectMessages": "Show message badge for all new messages", |
125 | "settings.service.form.enableAudio": "Enable audio", | 125 | "settings.service.form.enableAudio": "Enable audio", |
126 | "settings.service.form.isMutedInfo": "When disabled, all notification sounds and audio playback are muted", | 126 | "settings.service.form.isMutedInfo": "When disabled, all notification sounds and audio playback are muted", |
127 | "settings.service.form.buttonClearCache": "Clear cache", | ||
128 | "settings.service.form.buttonClearingCache": "Clearing cache...", | ||
129 | "settings.service.form.headlineNotifications": "Notifications", | 127 | "settings.service.form.headlineNotifications": "Notifications", |
130 | "settings.service.form.headlineBadges": "Unread message badges", | 128 | "settings.service.form.headlineBadges": "Unread message badges", |
131 | "settings.service.form.headlineGeneral": "General", | 129 | "settings.service.form.headlineGeneral": "General", |
@@ -151,8 +149,8 @@ | |||
151 | "settings.app.updateStatusSearching": "Is searching for update", | 149 | "settings.app.updateStatusSearching": "Is searching for update", |
152 | "settings.app.updateStatusAvailable": "Update available, downloading...", | 150 | "settings.app.updateStatusAvailable": "Update available, downloading...", |
153 | "settings.app.updateStatusUpToDate": "You are using the latest version of Franz", | 151 | "settings.app.updateStatusUpToDate": "You are using the latest version of Franz", |
154 | "settings.app.buttonClearAllCache": "Clear global cache for Franz and all services", | 152 | "settings.app.cacheInfo": "Franz cache is currently using {size} of disk space.", |
155 | "settings.app.buttonClearingAllCache": "Clearing global cache...", | 153 | "settings.app.buttonClearAllCache": "Clear cache", |
156 | "settings.app.form.autoLaunchOnStart": "Launch Franz on start", | 154 | "settings.app.form.autoLaunchOnStart": "Launch Franz on start", |
157 | "settings.app.form.autoLaunchInBackground": "Open in background", | 155 | "settings.app.form.autoLaunchInBackground": "Open in background", |
158 | "settings.app.form.enableSystemTray": "Show Franz in system tray", | 156 | "settings.app.form.enableSystemTray": "Show Franz in system tray", |
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index ac8d15632..63130a3ba 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -1,10 +1,11 @@ | |||
1 | import { remote, ipcRenderer, shell } from 'electron'; | 1 | import { remote, ipcRenderer, shell } from 'electron'; |
2 | import { action, observable } from 'mobx'; | 2 | import { action, computed, observable } from 'mobx'; |
3 | import moment from 'moment'; | 3 | import moment from 'moment'; |
4 | import key from 'keymaster'; | 4 | import key from 'keymaster'; |
5 | import { getDoNotDisturb } from '@meetfranz/electron-notification-state'; | 5 | import { getDoNotDisturb } from '@meetfranz/electron-notification-state'; |
6 | import idleTimer from '@paulcbetts/system-idle-time'; | 6 | import idleTimer from '@paulcbetts/system-idle-time'; |
7 | import AutoLaunch from 'auto-launch'; | 7 | import AutoLaunch from 'auto-launch'; |
8 | import prettyBytes from 'pretty-bytes'; | ||
8 | 9 | ||
9 | import Store from './lib/Store'; | 10 | import Store from './lib/Store'; |
10 | import Request from './lib/Request'; | 11 | import Request from './lib/Request'; |
@@ -14,7 +15,7 @@ import locales from '../i18n/translations'; | |||
14 | import { gaEvent } from '../lib/analytics'; | 15 | import { gaEvent } from '../lib/analytics'; |
15 | import Miner from '../lib/Miner'; | 16 | import Miner from '../lib/Miner'; |
16 | 17 | ||
17 | import { getServiceIdsFromPartitions } from '../helpers/service-helpers.js'; | 18 | import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; |
18 | 19 | ||
19 | const { app, powerMonitor } = remote; | 20 | const { app, powerMonitor } = remote; |
20 | const defaultLocale = DEFAULT_APP_SETTINGS.locale; | 21 | const defaultLocale = DEFAULT_APP_SETTINGS.locale; |
@@ -32,6 +33,7 @@ export default class AppStore extends Store { | |||
32 | }; | 33 | }; |
33 | 34 | ||
34 | @observable healthCheckRequest = new Request(this.api.app, 'health'); | 35 | @observable healthCheckRequest = new Request(this.api.app, 'health'); |
36 | @observable getAppCacheSizeRequest = new Request(this.api.local, 'getAppCacheSize'); | ||
35 | @observable clearAppCacheRequest = new Request(this.api.local, 'clearAppCache'); | 37 | @observable clearAppCacheRequest = new Request(this.api.local, 'clearAppCache'); |
36 | 38 | ||
37 | @observable autoLaunchOnStart = true; | 39 | @observable autoLaunchOnStart = true; |
@@ -163,6 +165,10 @@ export default class AppStore extends Store { | |||
163 | this._healthCheck(); | 165 | this._healthCheck(); |
164 | } | 166 | } |
165 | 167 | ||
168 | @computed get cacheSize() { | ||
169 | return prettyBytes(this.getAppCacheSizeRequest.execute().result || 0); | ||
170 | } | ||
171 | |||
166 | // Actions | 172 | // Actions |
167 | @action _notify({ title, options, notificationId, serviceId = null }) { | 173 | @action _notify({ title, options, notificationId, serviceId = null }) { |
168 | if (this.stores.settings.all.isAppMuted) return; | 174 | if (this.stores.settings.all.isAppMuted) return; |
@@ -256,9 +262,17 @@ export default class AppStore extends Store { | |||
256 | @action async _clearAllCache() { | 262 | @action async _clearAllCache() { |
257 | this.isClearingAllCache = true; | 263 | this.isClearingAllCache = true; |
258 | const clearAppCache = this.clearAppCacheRequest.execute(); | 264 | const clearAppCache = this.clearAppCacheRequest.execute(); |
259 | const serviceIds = await getServiceIdsFromPartitions(); | 265 | const allServiceIds = await getServiceIdsFromPartitions(); |
260 | await Promise.all(serviceIds.map(id => this.actions.service.clearCache({ serviceId: id }))); | 266 | const allOrphanedServiceIds = allServiceIds.filter(id => !this.stores.services.all.find(s => id.replace('service-', '') === s.id)); |
267 | |||
268 | await Promise.all(allOrphanedServiceIds.map(id => removeServicePartitionDirectory(id))); | ||
269 | |||
270 | await Promise.all(this.stores.services.all.map(s => this.actions.service.clearCache({ serviceId: s.id }))); | ||
271 | |||
261 | await clearAppCache._promise; | 272 | await clearAppCache._promise; |
273 | |||
274 | this.getAppCacheSizeRequest.execute(); | ||
275 | |||
262 | this.isClearingAllCache = false; | 276 | this.isClearingAllCache = false; |
263 | } | 277 | } |
264 | 278 | ||
@@ -333,6 +333,10 @@ async@^0.9.0: | |||
333 | version "0.9.2" | 333 | version "0.9.2" |
334 | resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" | 334 | resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" |
335 | 335 | ||
336 | async@~0.1.22: | ||
337 | version "0.1.22" | ||
338 | resolved "https://registry.yarnpkg.com/async/-/async-0.1.22.tgz#0fc1aaa088a0e3ef0ebe2d8831bab0dcf8845061" | ||
339 | |||
336 | asynckit@^0.4.0: | 340 | asynckit@^0.4.0: |
337 | version "0.4.0" | 341 | version "0.4.0" |
338 | resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" | 342 | resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" |
@@ -1783,6 +1787,12 @@ dotenv@^4.0.0: | |||
1783 | version "4.0.0" | 1787 | version "4.0.0" |
1784 | resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d" | 1788 | resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d" |
1785 | 1789 | ||
1790 | du@^0.1.0: | ||
1791 | version "0.1.0" | ||
1792 | resolved "https://registry.yarnpkg.com/du/-/du-0.1.0.tgz#f26e340a09c7bc5b6fd69af6dbadea60fa8c6f4d" | ||
1793 | dependencies: | ||
1794 | async "~0.1.22" | ||
1795 | |||
1786 | duplexer2@0.0.2, duplexer2@~0.0.2: | 1796 | duplexer2@0.0.2, duplexer2@~0.0.2: |
1787 | version "0.0.2" | 1797 | version "0.0.2" |
1788 | resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" | 1798 | resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" |
@@ -4895,6 +4905,10 @@ pretty-bytes@^1.0.2, pretty-bytes@^1.0.4: | |||
4895 | get-stdin "^4.0.1" | 4905 | get-stdin "^4.0.1" |
4896 | meow "^3.1.0" | 4906 | meow "^3.1.0" |
4897 | 4907 | ||
4908 | pretty-bytes@^4.0.2: | ||
4909 | version "4.0.2" | ||
4910 | resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9" | ||
4911 | |||
4898 | pretty-hrtime@^1.0.0: | 4912 | pretty-hrtime@^1.0.0: |
4899 | version "1.0.3" | 4913 | version "1.0.3" |
4900 | resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" | 4914 | resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" |