Skip to content

Commit

Permalink
Rename restoredFromThreeBox to showRestorePrompt
Browse files Browse the repository at this point in the history
  • Loading branch information
danjm committed Sep 26, 2019
1 parent 03820be commit 2cddae3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 26 deletions.
15 changes: 6 additions & 9 deletions app/scripts/controllers/threebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ThreeBoxController {

const initState = {
threeBoxSyncingAllowed: false,
restoredFromThreeBox: null,
showRestorePrompt: true,
threeBoxLastUpdated: 0,
...opts.initState,
threeBoxAddress: null,
Expand Down Expand Up @@ -85,7 +85,7 @@ class ThreeBoxController {
}

await this.space.private.set('metamaskBackup', JSON.stringify(newState))
await this.setRestoredFromThreeBoxToFalse()
await this.setShowRestorePromptToFalse()
}
} catch (error) {
console.error(error)
Expand Down Expand Up @@ -153,6 +153,7 @@ class ThreeBoxController {

clearTimeout(syncTimeout)
this.store.updateState(stateUpdate)

log.debug('3Box space sync done')
},
})
Expand Down Expand Up @@ -193,7 +194,7 @@ class ThreeBoxController {
this.store.updateState({ threeBoxLastUpdated: backedUpState.lastUpdated })
preferences && this.preferencesController.store.updateState(JSON.parse(preferences))
addressBook && this.addressBookController.update(JSON.parse(addressBook), true)
this.setRestoredFromThreeBoxToTrue()
this.setShowRestorePromptToFalse()
}

turnThreeBoxSyncingOn () {
Expand All @@ -204,12 +205,8 @@ class ThreeBoxController {
this.box.logout()
}

setRestoredFromThreeBoxToTrue () {
this.store.updateState({ restoredFromThreeBox: true })
}

setRestoredFromThreeBoxToFalse () {
this.store.updateState({ restoredFromThreeBox: false })
setShowRestorePromptToFalse () {
this.store.updateState({ showRestorePrompt: false })
}

setThreeBoxSyncingPermission (newThreeboxSyncingState) {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ module.exports = class MetamaskController extends EventEmitter {
// 3Box
setThreeBoxSyncingPermission: nodeify(threeBoxController.setThreeBoxSyncingPermission, threeBoxController),
restoreFromThreeBox: nodeify(threeBoxController.restoreFromThreeBox, threeBoxController),
setRestoredFromThreeBoxToFalse: nodeify(threeBoxController.setRestoredFromThreeBoxToFalse, threeBoxController),
setShowRestorePromptToFalse: nodeify(threeBoxController.setShowRestorePromptToFalse, threeBoxController),
getThreeBoxLastUpdated: nodeify(threeBoxController.getLastUpdated, threeBoxController),
turnThreeBoxSyncingOn: nodeify(threeBoxController.turnThreeBoxSyncingOn, threeBoxController),
initializeThreeBox: nodeify(this.initializeThreeBox, this),
Expand Down
16 changes: 8 additions & 8 deletions ui/app/pages/home/home.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export default class Home extends PureComponent {
threeBoxSynced: PropTypes.bool,
setupThreeBox: PropTypes.func,
turnThreeBoxSyncingOn: PropTypes.func,
restoredFromThreeBox: PropTypes.bool,
showRestorePrompt: PropTypes.bool,
selectedAddress: PropTypes.string,
restoreFromThreeBox: PropTypes.func,
setRestoredFromThreeBoxToFalse: PropTypes.func,
setShowRestorePromptToFalse: PropTypes.func,
threeBoxLastUpdated: PropTypes.string,
}

Expand Down Expand Up @@ -72,10 +72,10 @@ export default class Home extends PureComponent {
const {
threeBoxSynced,
setupThreeBox,
restoredFromThreeBox,
showRestorePrompt,
threeBoxLastUpdated,
} = this.props
if (threeBoxSynced && restoredFromThreeBox === null && threeBoxLastUpdated === null) {
if (threeBoxSynced && showRestorePrompt && threeBoxLastUpdated === null) {
setupThreeBox()
}
}
Expand All @@ -93,8 +93,8 @@ export default class Home extends PureComponent {
selectedAddress,
restoreFromThreeBox,
turnThreeBoxSyncingOn,
setRestoredFromThreeBoxToFalse,
restoredFromThreeBox,
setShowRestorePromptToFalse,
showRestorePrompt,
threeBoxLastUpdated,
} = this.props

Expand Down Expand Up @@ -153,7 +153,7 @@ export default class Home extends PureComponent {
/>,
},
{
shouldBeRendered: threeBoxLastUpdated && restoredFromThreeBox === null,
shouldBeRendered: threeBoxLastUpdated && showRestorePrompt,
component: <HomeNotification
descriptionText={t('restoreWalletPreferences', [ formatDate(parseInt(threeBoxLastUpdated), 'M/d/y') ])}
acceptText={t('restore')}
Expand All @@ -166,7 +166,7 @@ export default class Home extends PureComponent {
})
}}
onIgnore={() => {
setRestoredFromThreeBoxToFalse()
setShowRestorePromptToFalse()
}}
key="home-privacyModeDefault"
/>,
Expand Down
10 changes: 5 additions & 5 deletions ui/app/pages/home/home.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
restoreFromThreeBox,
turnThreeBoxSyncingOn,
getThreeBoxLastUpdated,
setRestoredFromThreeBoxToFalse,
setShowRestorePromptToFalse,
} from '../../store/actions'
import { setThreeBoxLastUpdated } from '../../ducks/app/app'
import { getEnvironmentType } from '../../../../app/scripts/lib/util'
Expand All @@ -24,7 +24,7 @@ const mapStateToProps = state => {
seedPhraseBackedUp,
tokens,
threeBoxSynced,
restoredFromThreeBox,
showRestorePrompt,
selectedAddress,
} = metamask
const accountBalance = getCurrentEthBalance(state)
Expand All @@ -41,7 +41,7 @@ const mapStateToProps = state => {
shouldShowSeedPhraseReminder: !seedPhraseBackedUp && (parseInt(accountBalance, 16) > 0 || tokens.length > 0),
isPopup,
threeBoxSynced,
restoredFromThreeBox,
showRestorePrompt,
selectedAddress,
threeBoxLastUpdated,
}
Expand All @@ -56,13 +56,13 @@ const mapDispatchToProps = (dispatch) => ({
if (lastUpdated) {
dispatch(setThreeBoxLastUpdated(lastUpdated))
} else {
dispatch(setRestoredFromThreeBoxToFalse())
dispatch(setShowRestorePromptToFalse())
dispatch(turnThreeBoxSyncingOn())
}
})
},
restoreFromThreeBox: (address) => dispatch(restoreFromThreeBox(address)),
setRestoredFromThreeBoxToFalse: () => dispatch(setRestoredFromThreeBoxToFalse()),
setShowRestorePromptToFalse: () => dispatch(setShowRestorePromptToFalse()),
})

export default compose(
Expand Down
6 changes: 3 additions & 3 deletions ui/app/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ var actions = {
restoreFromThreeBox,
getThreeBoxLastUpdated,
setThreeBoxSyncingPermission,
setRestoredFromThreeBoxToFalse,
setShowRestorePromptToFalse,
turnThreeBoxSyncingOn,
turnThreeBoxSyncingOnAndInitialize,
}
Expand Down Expand Up @@ -2811,10 +2811,10 @@ function initializeThreeBox () {
}
}

function setRestoredFromThreeBoxToFalse () {
function setShowRestorePromptToFalse () {
return (dispatch) => {
return new Promise((resolve, reject) => {
background.setRestoredFromThreeBoxToFalse((err) => {
background.setShowRestorePromptToFalse((err) => {
if (err) {
dispatch(actions.displayWarning(err.message))
return reject(err)
Expand Down

0 comments on commit 2cddae3

Please sign in to comment.