From 9c6ec054b13f24e88b78ca4124b0d3a46234b1d7 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 3 May 2016 15:04:15 -0700 Subject: Show any pending txs when unlocking Before the unlock action hard-routed to the home route, now it has a condition where it will show pending transactions instead. --- ui/app/actions.js | 1 - ui/app/app.js | 19 +++++++++++++++++-- ui/app/conf-tx.js | 3 ++- ui/app/reducers/app.js | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) (limited to 'ui/app') diff --git a/ui/app/actions.js b/ui/app/actions.js index 72550ff15..072139e1a 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -113,7 +113,6 @@ function tryUnlockMetamask(password) { dispatch(this.unlockFailed()) } else { dispatch(this.unlockMetamask()) - dispatch(this.showAccountDetail(selectedAccount)) } }) } diff --git a/ui/app/app.js b/ui/app/app.js index fce98d8e1..94c72a3c8 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -23,6 +23,7 @@ const ConfirmTxScreen = require('./conf-tx') const ConfigScreen = require('./config') const InfoScreen = require('./info') const LoadingIndicator = require('./loading') +const txHelper = require('../lib/tx-helper') module.exports = connect(mapStateToProps)(App) @@ -39,6 +40,8 @@ function mapStateToProps(state) { activeAddress: state.appState.activeAddress, transForward: state.appState.transForward, seedWords: state.metamask.seedWords, + unconfTxs: state.metamask.unconfTxs, + unconfMsgs: state.metamask.unconfMsgs, } } @@ -202,8 +205,20 @@ App.prototype.renderPrimary = function(state){ return h(CreateVaultScreen, {key: 'createVault'}) default: - return h(AccountDetailScreen, {key: 'account-detail'}) - } + if (this.hasPendingTxs()) { + return h(ConfirmTxScreen, {key: 'confirm-tx'}) + } else { + return h(AccountDetailScreen, {key: 'account-detail'}) + } + } +} + +App.prototype.hasPendingTxs = function() { + var state = this.props + var unconfTxs = state.unconfTxs + var unconfMsgs = state.unconfMsgs + var unconfTxList = txHelper(unconfTxs, unconfMsgs) + return unconfTxList.length > 0 } function onOffToggle(state){ diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js index d49d1f84c..8ab79c3b9 100644 --- a/ui/app/conf-tx.js +++ b/ui/app/conf-tx.js @@ -38,7 +38,8 @@ ConfirmTxScreen.prototype.render = function() { var unconfTxs = state.unconfTxs var unconfMsgs = state.unconfMsgs var unconfTxList = txHelper(unconfTxs, unconfMsgs) - var txData = unconfTxList[state.index] || {} + var index = state.index !== undefined ? state.index : 0 + var txData = unconfTxList[index] || {} return ( diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index fb03ffeee..14f92a8c5 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -108,6 +108,7 @@ function reduceApp(state, action) { case actions.UNLOCK_METAMASK: return extend(appState, { + currentView: {}, transForward: true, warning: null, }) -- cgit