From 7c2088720e164475ac4ce32b8fcdd661faef4d09 Mon Sep 17 00:00:00 2001 From: meriadec Date: Tue, 16 Oct 2018 13:57:49 +0200 Subject: [PATCH 1/3] Ensure sqlite folder is removed after clear cache / hard reset closes #1554 --- src/components/SettingsPage/CleanButton.js | 12 ++++-- src/components/SettingsPage/ResetButton.js | 11 ++++- .../SettingsPage/ResetFallbackModal.js | 41 +++++++++++++++++++ src/config/errors.js | 1 + src/helpers/reset.js | 15 ++++++- 5 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 src/components/SettingsPage/ResetFallbackModal.js diff --git a/src/components/SettingsPage/CleanButton.js b/src/components/SettingsPage/CleanButton.js index 629c551f76..f6d0ae9454 100644 --- a/src/components/SettingsPage/CleanButton.js +++ b/src/components/SettingsPage/CleanButton.js @@ -8,6 +8,7 @@ import { cleanAccountsCache } from 'actions/accounts' import Button from 'components/base/Button' import { ConfirmModal } from 'components/base/Modal' import { softReset } from 'helpers/reset' +import ResetFallbackModal from './ResetFallbackModal' const mapDispatchToProps = { cleanAccountsCache, @@ -20,32 +21,35 @@ type Props = { type State = { opened: boolean, + fallbackOpened: boolean, isLoading: boolean, } class CleanButton extends PureComponent { state = { opened: false, + fallbackOpened: false, isLoading: false, } open = () => this.setState({ opened: true }) close = () => this.setState({ opened: false }) + closeFallback = () => this.setState({ fallbackOpened: false }) action = async () => { if (this.state.isLoading) return try { this.setState({ isLoading: true }) await softReset({ cleanAccountsCache: this.props.cleanAccountsCache }) - } finally { - this.setState({ isLoading: false }) + } catch (err) { + this.setState({ isLoading: false, fallbackOpened: true }) } } render() { const { t } = this.props - const { opened, isLoading } = this.state + const { opened, isLoading, fallbackOpened } = this.state return (