diff --git a/src/components/SettingsPage/CleanButton.js b/src/components/SettingsPage/CleanButton.js index 629c551f..0f72d21f 100644 --- a/src/components/SettingsPage/CleanButton.js +++ b/src/components/SettingsPage/CleanButton.js @@ -3,11 +3,13 @@ import React, { Fragment, PureComponent } from 'react' import { connect } from 'react-redux' import { translate } from 'react-i18next' +import logger from 'logger' import type { T } from 'types/common' 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 +22,36 @@ 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) { + logger.error(err) + this.setState({ isLoading: false, fallbackOpened: true }) } } render() { const { t } = this.props - const { opened, isLoading } = this.state + const { opened, isLoading, fallbackOpened } = this.state return (