Skip to content

Commit

Permalink
Only render confirm screen before home screen on mount.
Browse files Browse the repository at this point in the history
  • Loading branch information
danjm committed Apr 25, 2019
1 parent fe1b940 commit 3bc2cda
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 13 additions & 6 deletions ui/app/pages/home/home.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,7 +51,7 @@ export default class Home extends PureComponent {
forgottenPassword,
seedWords,
providerRequests,
unconfirmedTransactionsCount,
history,
} = this.props

// seed words
Expand All @@ -59,17 +69,14 @@ export default class Home extends PureComponent {
)
}

if (unconfirmedTransactionsCount > 0) {
return <Redirect to={{ pathname: CONFIRM_TRANSACTION_ROUTE }} />
}
return (
<div className="main-container">
<div className="account-and-transaction-details">
<Media
query="(min-width: 576px)"
render={() => <WalletView />}
/>
<TransactionView />
{ !history.location.pathname.match(/^\/confirm-transaction/) ? <TransactionView /> : null }
</div>
</div>
)
Expand Down

0 comments on commit 3bc2cda

Please sign in to comment.