@ -56,51 +56,61 @@ export default class Home extends PureComponent {
onTabClick : PropTypes . func . isRequired ,
onTabClick : PropTypes . func . isRequired ,
}
}
UNSAFE _componentWillMount ( ) {
state = {
const {
mounted : false ,
history ,
unconfirmedTransactionsCount = 0 ,
firstPermissionsRequestId ,
} = this . props
if ( firstPermissionsRequestId ) {
history . push ( ` ${ CONNECT _ROUTE } / ${ firstPermissionsRequestId } ` )
}
if ( unconfirmedTransactionsCount > 0 ) {
history . push ( CONFIRM _TRANSACTION _ROUTE )
}
}
}
componentDidMount ( ) {
componentDidMount ( ) {
const {
const {
firstPermissionsRequestId ,
history ,
history ,
isNotification ,
isNotification ,
suggestedTokens = { } ,
suggestedTokens = { } ,
totalUnapprovedCount ,
totalUnapprovedCount ,
unconfirmedTransactionsCount ,
} = this . props
} = this . props
this . setState ( { mounted : true } )
if ( isNotification && totalUnapprovedCount === 0 ) {
if ( isNotification && totalUnapprovedCount === 0 ) {
global . platform . closeCurrentWindow ( )
global . platform . closeCurrentWindow ( )
} else if ( firstPermissionsRequestId ) {
history . push ( ` ${ CONNECT _ROUTE } / ${ firstPermissionsRequestId } ` )
} else if ( unconfirmedTransactionsCount > 0 ) {
history . push ( CONFIRM _TRANSACTION _ROUTE )
} else if ( Object . keys ( suggestedTokens ) . length > 0 ) {
history . push ( CONFIRM _ADD _SUGGESTED _TOKEN _ROUTE )
}
}
}
// suggested new tokens
static getDerivedStateFromProps (
if ( Object . keys ( suggestedTokens ) . length > 0 ) {
{
history . push ( CONFIRM _ADD _SUGGESTED _TOKEN _ROUTE )
firstPermissionsRequestId ,
isNotification ,
suggestedTokens ,
totalUnapprovedCount ,
unconfirmedTransactionsCount ,
} ,
{ mounted } ,
) {
if ( ! mounted ) {
if ( isNotification && totalUnapprovedCount === 0 ) {
return { closing : true }
} else if ( firstPermissionsRequestId || unconfirmedTransactionsCount > 0 || Object . keys ( suggestedTokens ) . length > 0 ) {
return { redirecting : true }
}
}
}
return null
}
}
componentDidUpdate ( ) {
componentDidUpdate ( _ , prevState ) {
const {
const {
isNotification ,
setupThreeBox ,
setupThreeBox ,
showRestorePrompt ,
showRestorePrompt ,
threeBoxLastUpdated ,
threeBoxLastUpdated ,
threeBoxSynced ,
threeBoxSynced ,
totalUnapprovedCount ,
} = this . props
} = this . props
if ( isNotification && totalUnapprovedCount === 0 ) {
if ( ! prevState . closing && this . state . closing ) {
global . platform . closeCurrentWindow ( )
global . platform . closeCurrentWindow ( )
}
}
@ -228,9 +238,7 @@ export default class Home extends PureComponent {
if ( forgottenPassword ) {
if ( forgottenPassword ) {
return < Redirect to = { { pathname : RESTORE _VAULT _ROUTE } } / >
return < Redirect to = { { pathname : RESTORE _VAULT _ROUTE } } / >
} else if ( history . location . pathname . match ( /^\/confirm-transaction/ ) ) {
} else if ( this . state . closing || this . state . redirecting ) {
// This should only happen if this renders during the redirect to the confirm page
// Display nothing while the confirm page loads, to avoid side-effects of rendering normal home view
return null
return null
}
}