aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-05-13 11:58:35 +0200
committerLibravatar GitHub <noreply@github.com>2021-05-13 11:58:35 +0200
commit5db9f585e8cec20abdadf431d667422af66cf692 (patch)
treec1d7d57c5d9370385249acba1bedcfb931d42158 /src/components
parentNew Crowdin updates for Japanese (#1406) (diff)
downloadferdium-app-5db9f585e8cec20abdadf431d667422af66cf692.tar.gz
ferdium-app-5db9f585e8cec20abdadf431d667422af66cf692.tar.zst
ferdium-app-5db9f585e8cec20abdadf431d667422af66cf692.zip
Lazily compute cache size (#1404)
Computing the cache size can take a long time if the cache is large. Previously, cache size computation was triggered by opening the Settings pane, which slowed down changing settings even if the user wasn't interested in the cache size. This patch defers cache size computation until the Advanced tab is open in the Setting page. Additionally, cache size rendering (in MB / GB) is moved from the AppStore into the EditSettingsForm to fix the notCleared functionality.
Diffstat (limited to 'src/components')
-rw-r--r--src/components/settings/settings/EditSettingsForm.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js
index f7840c5bb..7a0aead15 100644
--- a/src/components/settings/settings/EditSettingsForm.js
+++ b/src/components/settings/settings/EditSettingsForm.js
@@ -2,6 +2,7 @@ import { remote } from 'electron';
2import React, { Component, Fragment } from 'react'; 2import React, { Component, Fragment } from 'react';
3import PropTypes from 'prop-types'; 3import PropTypes from 'prop-types';
4import { observer } from 'mobx-react'; 4import { observer } from 'mobx-react';
5import prettyBytes from 'pretty-bytes';
5import { defineMessages, intlShape } from 'react-intl'; 6import { defineMessages, intlShape } from 'react-intl';
6 7
7import Form from '../../../lib/Form'; 8import Form from '../../../lib/Form';
@@ -165,7 +166,7 @@ export default @observer class EditSettingsForm extends Component {
165 updateIsReadyToInstall: PropTypes.bool.isRequired, 166 updateIsReadyToInstall: PropTypes.bool.isRequired,
166 isClearingAllCache: PropTypes.bool.isRequired, 167 isClearingAllCache: PropTypes.bool.isRequired,
167 onClearAllCache: PropTypes.func.isRequired, 168 onClearAllCache: PropTypes.func.isRequired,
168 cacheSize: PropTypes.string.isRequired, 169 getCacheSize: PropTypes.func.isRequired,
169 isSpellcheckerIncludedInCurrentPlan: PropTypes.bool.isRequired, 170 isSpellcheckerIncludedInCurrentPlan: PropTypes.bool.isRequired,
170 isTodosEnabled: PropTypes.bool.isRequired, 171 isTodosEnabled: PropTypes.bool.isRequired,
171 isTodosActivated: PropTypes.bool.isRequired, 172 isTodosActivated: PropTypes.bool.isRequired,
@@ -221,7 +222,7 @@ export default @observer class EditSettingsForm extends Component {
221 updateIsReadyToInstall, 222 updateIsReadyToInstall,
222 isClearingAllCache, 223 isClearingAllCache,
223 onClearAllCache, 224 onClearAllCache,
224 cacheSize, 225 getCacheSize,
225 isSpellcheckerIncludedInCurrentPlan, 226 isSpellcheckerIncludedInCurrentPlan,
226 isTodosEnabled, 227 isTodosEnabled,
227 isWorkspaceEnabled, 228 isWorkspaceEnabled,
@@ -248,7 +249,20 @@ export default @observer class EditSettingsForm extends Component {
248 lockingFeatureEnabled, 249 lockingFeatureEnabled,
249 scheduledDNDEnabled, 250 scheduledDNDEnabled,
250 } = window.ferdi.stores.settings.all.app; 251 } = window.ferdi.stores.settings.all.app;
251 const notCleared = this.state.clearCacheButtonClicked && isClearingAllCache === false && cacheSize !== 0; 252
253 let cacheSize;
254 let notCleared;
255 if (this.state.activeSetttingsTab === 'advanced') {
256 const cacheSizeBytes = getCacheSize();
257 if (typeof cacheSizeBytes === 'number') {
258 cacheSize = prettyBytes(cacheSizeBytes);
259 notCleared = this.state.clearCacheButtonClicked && isClearingAllCache === false && cacheSizeBytes !== 0;
260 } else {
261 cacheSize = '…';
262 notCleared = false;
263 }
264 }
265
252 return ( 266 return (
253 <div className="settings__main"> 267 <div className="settings__main">
254 <div className="settings__header"> 268 <div className="settings__header">