|
@ -5,6 +5,7 @@ import { connect } from 'react-redux' |
|
|
import { remote } from 'electron' |
|
|
import { remote } from 'electron' |
|
|
import bcrypt from 'bcryptjs' |
|
|
import bcrypt from 'bcryptjs' |
|
|
|
|
|
|
|
|
|
|
|
import libcoreHardReset from 'commands/libcoreHardReset' |
|
|
import { cleanAccountsCache } from 'actions/accounts' |
|
|
import { cleanAccountsCache } from 'actions/accounts' |
|
|
import { unlock } from 'reducers/application' // FIXME should be in actions
|
|
|
import { unlock } from 'reducers/application' // FIXME should be in actions
|
|
|
import db, { setEncryptionKey } from 'helpers/db' |
|
|
import db, { setEncryptionKey } from 'helpers/db' |
|
@ -47,6 +48,7 @@ type State = { |
|
|
isSoftResetModalOpened: boolean, |
|
|
isSoftResetModalOpened: boolean, |
|
|
isPasswordModalOpened: boolean, |
|
|
isPasswordModalOpened: boolean, |
|
|
isDisablePasswordModalOpened: boolean, |
|
|
isDisablePasswordModalOpened: boolean, |
|
|
|
|
|
isHardResetting: boolean, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class TabProfile extends PureComponent<Props, State> { |
|
|
class TabProfile extends PureComponent<Props, State> { |
|
@ -55,6 +57,7 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
isSoftResetModalOpened: false, |
|
|
isSoftResetModalOpened: false, |
|
|
isPasswordModalOpened: false, |
|
|
isPasswordModalOpened: false, |
|
|
isDisablePasswordModalOpened: false, |
|
|
isDisablePasswordModalOpened: false, |
|
|
|
|
|
isHardResetting: false, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
setPassword = password => { |
|
|
setPassword = password => { |
|
@ -89,9 +92,17 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handleHardReset = async () => { |
|
|
handleHardReset = async () => { |
|
|
db.resetAll() |
|
|
this.setState({ isHardResetting: true }) |
|
|
await delay(500) |
|
|
try { |
|
|
remote.getCurrentWindow().webContents.reload() |
|
|
// TODO: wait for the libcoreHardReset to be finished
|
|
|
|
|
|
// actually, libcore doesnt goes back to js thread
|
|
|
|
|
|
await Promise.race([libcoreHardReset.send().toPromise(), delay(500)]) |
|
|
|
|
|
db.resetAll() |
|
|
|
|
|
await delay(500) |
|
|
|
|
|
remote.getCurrentWindow().webContents.reload() |
|
|
|
|
|
} catch (err) { |
|
|
|
|
|
this.setState({ isHardResetting: false }) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handleChangePasswordCheck = isChecked => { |
|
|
handleChangePasswordCheck = isChecked => { |
|
@ -125,6 +136,7 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
isHardResetModalOpened, |
|
|
isHardResetModalOpened, |
|
|
isPasswordModalOpened, |
|
|
isPasswordModalOpened, |
|
|
isDisablePasswordModalOpened, |
|
|
isDisablePasswordModalOpened, |
|
|
|
|
|
isHardResetting, |
|
|
} = this.state |
|
|
} = this.state |
|
|
const isPasswordEnabled = settings.password.isEnabled === true |
|
|
const isPasswordEnabled = settings.password.isEnabled === true |
|
|
return ( |
|
|
return ( |
|
@ -200,6 +212,7 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
|
|
|
|
|
|
<ConfirmModal |
|
|
<ConfirmModal |
|
|
isDanger |
|
|
isDanger |
|
|
|
|
|
isLoading={isHardResetting} |
|
|
isOpened={isHardResetModalOpened} |
|
|
isOpened={isHardResetModalOpened} |
|
|
onClose={this.handleCloseHardResetModal} |
|
|
onClose={this.handleCloseHardResetModal} |
|
|
onReject={this.handleCloseHardResetModal} |
|
|
onReject={this.handleCloseHardResetModal} |
|
|