From 3bc2cda94b42b43f70e0a46aa926804aadaa4eaf Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Thu, 25 Apr 2019 15:08:56 -0230 Subject: [PATCH] Only render confirm screen before home screen on mount. --- .../confirm-transaction-base.component.js | 7 +++++-- ui/app/pages/home/home.component.js | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js index be819b5f0ed0..1dbc2a47f292 100644 --- a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -99,15 +99,18 @@ export default class ConfirmTransactionBase extends Component { submitError: null, } - componentDidUpdate () { + componentDidUpdate (prevProps) { const { transactionStatus, showTransactionConfirmedModal, history, clearConfirmTransaction, } = this.props + const { transactionStatus: prevTxStatus } = prevProps + const statusUpdated = transactionStatus !== prevTxStatus + const txDroppedOrConfirmed = transactionStatus === DROPPED_STATUS || transactionStatus === CONFIRMED_STATUS - if (transactionStatus === DROPPED_STATUS || transactionStatus === CONFIRMED_STATUS) { + if (statusUpdated && txDroppedOrConfirmed) { showTransactionConfirmedModal({ onSubmit: () => { clearConfirmTransaction() diff --git a/ui/app/pages/home/home.component.js b/ui/app/pages/home/home.component.js index 78a80eb0d3ce..4d96c3131489 100644 --- a/ui/app/pages/home/home.component.js +++ b/ui/app/pages/home/home.component.js @@ -23,11 +23,21 @@ export default class Home extends PureComponent { providerRequests: PropTypes.array, } + componentWillMount () { + const { + history, + unconfirmedTransactionsCount = 0, + } = this.props + + if (unconfirmedTransactionsCount > 0) { + history.push(CONFIRM_TRANSACTION_ROUTE) + } + } + componentDidMount () { const { history, suggestedTokens = {}, - unconfirmedTransactionsCount = 0, } = this.props // suggested new tokens @@ -41,7 +51,7 @@ export default class Home extends PureComponent { forgottenPassword, seedWords, providerRequests, - unconfirmedTransactionsCount, + history, } = this.props // seed words @@ -59,9 +69,6 @@ export default class Home extends PureComponent { ) } - if (unconfirmedTransactionsCount > 0) { - return - } return (
@@ -69,7 +76,7 @@ export default class Home extends PureComponent { query="(min-width: 576px)" render={() => } /> - + { !history.location.pathname.match(/^\/confirm-transaction/) ? : null }
)