|
@ -5,12 +5,14 @@ import { connect } from 'react-redux' |
|
|
import { remote } from 'electron' |
|
|
import { remote } from 'electron' |
|
|
import bcrypt from 'bcryptjs' |
|
|
import bcrypt from 'bcryptjs' |
|
|
|
|
|
|
|
|
|
|
|
import { cleanAccountsCache } from 'actions/accounts' |
|
|
|
|
|
import { unlock } from 'reducers/application' // FIXME should be in actions
|
|
|
|
|
|
import db, { setEncryptionKey } from 'helpers/db' |
|
|
|
|
|
import { delay } from 'helpers/promise' |
|
|
|
|
|
|
|
|
import type { SettingsState } from 'reducers/settings' |
|
|
import type { SettingsState } from 'reducers/settings' |
|
|
import type { T } from 'types/common' |
|
|
import type { T } from 'types/common' |
|
|
|
|
|
|
|
|
import { unlock } from 'reducers/application' |
|
|
|
|
|
import db, { setEncryptionKey } from 'helpers/db' |
|
|
|
|
|
|
|
|
|
|
|
import CheckBox from 'components/base/CheckBox' |
|
|
import CheckBox from 'components/base/CheckBox' |
|
|
import Box from 'components/base/Box' |
|
|
import Box from 'components/base/Box' |
|
|
import Button from 'components/base/Button' |
|
|
import Button from 'components/base/Button' |
|
@ -28,6 +30,7 @@ import { |
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
const mapDispatchToProps = { |
|
|
unlock, |
|
|
unlock, |
|
|
|
|
|
cleanAccountsCache, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type Props = { |
|
|
type Props = { |
|
@ -35,10 +38,12 @@ type Props = { |
|
|
settings: SettingsState, |
|
|
settings: SettingsState, |
|
|
unlock: Function, |
|
|
unlock: Function, |
|
|
saveSettings: Function, |
|
|
saveSettings: Function, |
|
|
|
|
|
cleanAccountsCache: () => *, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type State = { |
|
|
type State = { |
|
|
isHardResetModalOpened: boolean, |
|
|
isHardResetModalOpened: boolean, |
|
|
|
|
|
isSoftResetModalOpened: boolean, |
|
|
isPasswordModalOpened: boolean, |
|
|
isPasswordModalOpened: boolean, |
|
|
isDisablePasswordModalOpened: boolean, |
|
|
isDisablePasswordModalOpened: boolean, |
|
|
} |
|
|
} |
|
@ -46,6 +51,7 @@ type State = { |
|
|
class TabProfile extends PureComponent<Props, State> { |
|
|
class TabProfile extends PureComponent<Props, State> { |
|
|
state = { |
|
|
state = { |
|
|
isHardResetModalOpened: false, |
|
|
isHardResetModalOpened: false, |
|
|
|
|
|
isSoftResetModalOpened: false, |
|
|
isPasswordModalOpened: false, |
|
|
isPasswordModalOpened: false, |
|
|
isDisablePasswordModalOpened: false, |
|
|
isDisablePasswordModalOpened: false, |
|
|
} |
|
|
} |
|
@ -65,6 +71,8 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleOpenSoftResetModal = () => this.setState({ isSoftResetModalOpened: true }) |
|
|
|
|
|
handleCloseSoftResetModal = () => this.setState({ isSoftResetModalOpened: false }) |
|
|
handleOpenHardResetModal = () => this.setState({ isHardResetModalOpened: true }) |
|
|
handleOpenHardResetModal = () => this.setState({ isHardResetModalOpened: true }) |
|
|
handleCloseHardResetModal = () => this.setState({ isHardResetModalOpened: false }) |
|
|
handleCloseHardResetModal = () => this.setState({ isHardResetModalOpened: false }) |
|
|
handleOpenPasswordModal = () => this.setState({ isPasswordModalOpened: true }) |
|
|
handleOpenPasswordModal = () => this.setState({ isPasswordModalOpened: true }) |
|
@ -72,6 +80,14 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
handleDisablePassowrd = () => this.setState({ isDisablePasswordModalOpened: true }) |
|
|
handleDisablePassowrd = () => this.setState({ isDisablePasswordModalOpened: true }) |
|
|
handleCloseDisablePasswordModal = () => this.setState({ isDisablePasswordModalOpened: false }) |
|
|
handleCloseDisablePasswordModal = () => this.setState({ isDisablePasswordModalOpened: false }) |
|
|
|
|
|
|
|
|
|
|
|
handleSoftReset = async () => { |
|
|
|
|
|
this.props.cleanAccountsCache() |
|
|
|
|
|
await delay(500) |
|
|
|
|
|
db.cleanCache() |
|
|
|
|
|
remote.app.relaunch() |
|
|
|
|
|
remote.app.exit() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
handleHardReset = () => { |
|
|
handleHardReset = () => { |
|
|
db.resetAll() |
|
|
db.resetAll() |
|
|
remote.app.relaunch() |
|
|
remote.app.relaunch() |
|
@ -105,6 +121,7 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
render() { |
|
|
render() { |
|
|
const { t, settings } = this.props |
|
|
const { t, settings } = this.props |
|
|
const { |
|
|
const { |
|
|
|
|
|
isSoftResetModalOpened, |
|
|
isHardResetModalOpened, |
|
|
isHardResetModalOpened, |
|
|
isPasswordModalOpened, |
|
|
isPasswordModalOpened, |
|
|
isDisablePasswordModalOpened, |
|
|
isDisablePasswordModalOpened, |
|
@ -134,13 +151,35 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
> |
|
|
> |
|
|
<CheckBox isChecked={settings.developerMode} onChange={this.handleDeveloperMode} /> |
|
|
<CheckBox isChecked={settings.developerMode} onChange={this.handleDeveloperMode} /> |
|
|
</Row> |
|
|
</Row> |
|
|
<Row title={t('settings:profile.reset')} desc={t('settings:profile.resetDesc')}> |
|
|
<Row |
|
|
|
|
|
title={t('settings:profile.softResetTitle')} |
|
|
|
|
|
desc={t('settings:profile.softResetDesc')} |
|
|
|
|
|
> |
|
|
|
|
|
<Button primary onClick={this.handleOpenSoftResetModal}> |
|
|
|
|
|
{t('settings:profile.softReset')} |
|
|
|
|
|
</Button> |
|
|
|
|
|
</Row> |
|
|
|
|
|
<Row |
|
|
|
|
|
title={t('settings:profile.hardResetTitle')} |
|
|
|
|
|
desc={t('settings:profile.hardResetDesc')} |
|
|
|
|
|
> |
|
|
<Button danger onClick={this.handleOpenHardResetModal}> |
|
|
<Button danger onClick={this.handleOpenHardResetModal}> |
|
|
{t('settings:profile.resetButton')} |
|
|
{t('settings:profile.hardReset')} |
|
|
</Button> |
|
|
</Button> |
|
|
</Row> |
|
|
</Row> |
|
|
</Body> |
|
|
</Body> |
|
|
|
|
|
|
|
|
|
|
|
<ConfirmModal |
|
|
|
|
|
isDanger |
|
|
|
|
|
isOpened={isSoftResetModalOpened} |
|
|
|
|
|
onClose={this.handleCloseSoftResetModal} |
|
|
|
|
|
onReject={this.handleCloseSoftResetModal} |
|
|
|
|
|
onConfirm={this.handleSoftReset} |
|
|
|
|
|
title={t('settings:softResetModal.title')} |
|
|
|
|
|
subTitle={t('settings:softResetModal.subTitle')} |
|
|
|
|
|
desc={t('settings:softResetModal.desc')} |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<ConfirmModal |
|
|
<ConfirmModal |
|
|
isDanger |
|
|
isDanger |
|
|
isOpened={isHardResetModalOpened} |
|
|
isOpened={isHardResetModalOpened} |
|
|