From 477b74124d24c9497fafb0c976eba27712c69d79 Mon Sep 17 00:00:00 2001 From: Alexander Tseung Date: Sat, 21 Apr 2018 22:23:45 -0700 Subject: [PATCH] Revert "Fix UI getting stuck in Reveal Seed screen" This reverts commit 2c8156ebe91941309d49e8f8f1ed8e9d740bb9de. --- app/scripts/lib/config-manager.js | 22 +----- app/scripts/metamask-controller.js | 2 - .../src/app/first-time/confirm-seed-screen.js | 14 +--- mascara/src/app/first-time/seed-screen.js | 71 +++++-------------- ui/app/actions.js | 16 +---- ui/app/app.js | 14 +--- 6 files changed, 23 insertions(+), 116 deletions(-) diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index 63d27c40e..34b603b96 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -102,6 +102,7 @@ ConfigManager.prototype.setShowSeedWords = function (should) { this.setData(data) } + ConfigManager.prototype.getShouldShowSeedWords = function () { var data = this.getData() return data.showSeedWords @@ -117,27 +118,6 @@ ConfigManager.prototype.getSeedWords = function () { var data = this.getData() return data.seedWords } - -/** - * Called to set the isRevealingSeedWords flag. This happens only when the user chooses to reveal - * the seed words and not during the first time flow. - * @param {boolean} reveal - Value to set the isRevealingSeedWords flag. - */ -ConfigManager.prototype.setIsRevealingSeedWords = function (reveal = false) { - const data = this.getData() - data.isRevealingSeedWords = reveal - this.setData(data) -} - -/** - * Returns the isRevealingSeedWords flag. - * @returns {boolean|undefined} - */ -ConfigManager.prototype.getIsRevealingSeedWords = function () { - const data = this.getData() - return data.isRevealingSeedWords -} - ConfigManager.prototype.setRpcTarget = function (rpcUrl) { var config = this.getConfig() config.provider = { diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 782bc50ac..a12b6776e 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -308,7 +308,6 @@ module.exports = class MetamaskController extends EventEmitter { lostAccounts: this.configManager.getLostAccounts(), seedWords: this.configManager.getSeedWords(), forgottenPassword: this.configManager.getPasswordForgotten(), - isRevealingSeedWords: Boolean(this.configManager.getIsRevealingSeedWords()), }, } } @@ -348,7 +347,6 @@ module.exports = class MetamaskController extends EventEmitter { clearSeedWordCache: this.clearSeedWordCache.bind(this), resetAccount: nodeify(this.resetAccount, this), importAccountWithStrategy: this.importAccountWithStrategy.bind(this), - setIsRevealingSeedWords: this.configManager.setIsRevealingSeedWords.bind(this.configManager), // vault management submitPassword: nodeify(keyringController.submitPassword, keyringController), diff --git a/mascara/src/app/first-time/confirm-seed-screen.js b/mascara/src/app/first-time/confirm-seed-screen.js index 7c0431431..438f383b1 100644 --- a/mascara/src/app/first-time/confirm-seed-screen.js +++ b/mascara/src/app/first-time/confirm-seed-screen.js @@ -9,7 +9,7 @@ import Identicon from '../../../../ui/app/components/identicon' import { confirmSeedWords, showModal } from '../../../../ui/app/actions' import Breadcrumbs from './breadcrumbs' import LoadingScreen from './loading-screen' -import { DEFAULT_ROUTE, INITIALIZE_BACKUP_PHRASE_ROUTE } from '../../../../ui/app/routes' +import { DEFAULT_ROUTE } from '../../../../ui/app/routes' class ConfirmSeedScreen extends Component { static propTypes = { @@ -53,7 +53,7 @@ class ConfirmSeedScreen extends Component { } render () { - const { seedWords, history } = this.props + const { seedWords } = this.props const { selectedSeeds, shuffledSeeds } = this.state const isValid = seedWords === selectedSeeds.map(([_, seed]) => seed).join(' ') @@ -66,16 +66,6 @@ class ConfirmSeedScreen extends Component {
- { - e.preventDefault() - history.push(INITIALIZE_BACKUP_PHRASE_ROUTE) - }} - href="#" - > - {`< Back`} -
diff --git a/mascara/src/app/first-time/seed-screen.js b/mascara/src/app/first-time/seed-screen.js index 9af9ca3be..d004be77b 100644 --- a/mascara/src/app/first-time/seed-screen.js +++ b/mascara/src/app/first-time/seed-screen.js @@ -8,7 +8,6 @@ import Identicon from '../../../../ui/app/components/identicon' import Breadcrumbs from './breadcrumbs' import LoadingScreen from './loading-screen' import { DEFAULT_ROUTE, INITIALIZE_CONFIRM_SEED_ROUTE } from '../../../../ui/app/routes' -import { confirmSeedWords } from '../../../../ui/app/actions' const LockIcon = props => ( clearSeedWords().then(() => history.push(DEFAULT_ROUTE))} - disabled={!isShowingSecret} - > - Done - - : - } - renderSecretScreen () { - const { isRevealingSeedWords } = this.props + const { isShowingSecret } = this.state + const { history } = this.props return (
@@ -152,8 +121,14 @@ class BackupPhraseScreen extends Component {
- { this.renderSubmitButton() } - { !isRevealingSeedWords && } + +
) @@ -175,25 +150,13 @@ class BackupPhraseScreen extends Component { } } -const mapStateToProps = ({ metamask, appState }) => { - const { selectedAddress, seedWords, isRevealingSeedWords } = metamask - const { isLoading } = appState - - return { - seedWords, - isRevealingSeedWords, - isLoading, - address: selectedAddress, - } -} - -const mapDispatchToProps = dispatch => { - return { - clearSeedWords: () => dispatch(confirmSeedWords()), - } -} - export default compose( withRouter, - connect(mapStateToProps, mapDispatchToProps), + connect( + ({ metamask: { selectedAddress, seedWords }, appState: { isLoading } }) => ({ + seedWords, + isLoading, + address: selectedAddress, + }) + ) )(BackupPhraseScreen) diff --git a/ui/app/actions.js b/ui/app/actions.js index 73335db97..f5cdd32bc 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -351,6 +351,7 @@ function confirmSeedWords () { log.debug(`background.clearSeedWordCache`) return new Promise((resolve, reject) => { background.clearSeedWordCache((err, account) => { + dispatch(actions.hideLoadingIndication()) if (err) { dispatch(actions.displayWarning(err.message)) return reject(err) @@ -361,9 +362,6 @@ function confirmSeedWords () { resolve(account) }) }) - .then(() => dispatch(setIsRevealingSeedWords(false))) - .then(() => dispatch(actions.hideLoadingIndication())) - .catch(() => dispatch(actions.hideLoadingIndication())) } } @@ -448,13 +446,11 @@ function requestRevealSeed (password) { } dispatch(actions.showNewVaultSeed(result)) + dispatch(actions.hideLoadingIndication()) resolve() }) }) }) - .then(() => dispatch(setIsRevealingSeedWords(true))) - .then(() => dispatch(actions.hideLoadingIndication())) - .catch(() => dispatch(actions.hideLoadingIndication())) } } @@ -1911,11 +1907,3 @@ function updateNetworkEndpointType (networkEndpointType) { value: networkEndpointType, } } - -function setIsRevealingSeedWords (reveal) { - return dispatch => { - log.debug(`background.setIsRevealingSeedWords`) - background.setIsRevealingSeedWords(reveal) - return forceUpdateMetamaskState(dispatch) - } -} diff --git a/ui/app/app.js b/ui/app/app.js index 0b38b1326..e462701fa 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -56,20 +56,11 @@ const { class App extends Component { componentWillMount () { - const { - currentCurrency, - setCurrentCurrencyToUSD, - isRevealingSeedWords, - clearSeedWords, - } = this.props + const { currentCurrency, setCurrentCurrencyToUSD } = this.props if (!currentCurrency) { setCurrentCurrencyToUSD() } - - if (isRevealingSeedWords) { - clearSeedWords() - } } renderRoutes () { @@ -402,8 +393,6 @@ App.propTypes = { isMouseUser: PropTypes.bool, setMouseUserState: PropTypes.func, t: PropTypes.func, - isRevealingSeedWords: PropTypes.bool, - clearSeedWords: PropTypes.func, } function mapStateToProps (state) { @@ -484,7 +473,6 @@ function mapDispatchToProps (dispatch, ownProps) { setCurrentCurrencyToUSD: () => dispatch(actions.setCurrentCurrency('usd')), toggleAccountMenu: () => dispatch(actions.toggleAccountMenu()), setMouseUserState: (isMouseUser) => dispatch(actions.setMouseUserState(isMouseUser)), - clearSeedWords: () => dispatch(actions.confirmSeedWords()), } }