Hide app-header when provider request pending (#5831)

feature/default_network_editable
Whymarrh Whitby 6 years ago committed by GitHub
parent 8198ec9ae1
commit 88defe3623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      ui/app/components/app-header/app-header.component.js
  2. 2
      ui/app/components/app-header/app-header.container.js

@ -23,6 +23,7 @@ export default class AppHeader extends PureComponent {
toggleAccountMenu: PropTypes.func, toggleAccountMenu: PropTypes.func,
selectedAddress: PropTypes.string, selectedAddress: PropTypes.string,
isUnlocked: PropTypes.bool, isUnlocked: PropTypes.bool,
providerRequests: PropTypes.array,
} }
static contextTypes = { static contextTypes = {
@ -40,12 +41,23 @@ export default class AppHeader extends PureComponent {
: hideNetworkDropdown() : hideNetworkDropdown()
} }
/**
* Returns whether or not the user is in the middle of a confirmation prompt
*
* This accounts for both tx confirmations as well as provider approvals
*
* @returns {boolean}
*/
isConfirming () { isConfirming () {
const { location } = this.props const { location, providerRequests } = this.props
const confirmTxRouteMatch = matchPath(location.pathname, {
return Boolean(matchPath(location.pathname, { exact: false,
path: CONFIRM_TRANSACTION_ROUTE, exact: false, path: CONFIRM_TRANSACTION_ROUTE,
})) })
const isConfirmingTx = Boolean(confirmTxRouteMatch)
const hasPendingProviderApprovals = Array.isArray(providerRequests) && providerRequests.length > 0
return isConfirmingTx || hasPendingProviderApprovals
} }
renderAccountMenu () { renderAccountMenu () {

@ -11,6 +11,7 @@ const mapStateToProps = state => {
const { const {
network, network,
provider, provider,
providerRequests,
selectedAddress, selectedAddress,
isUnlocked, isUnlocked,
} = metamask } = metamask
@ -19,6 +20,7 @@ const mapStateToProps = state => {
networkDropdownOpen, networkDropdownOpen,
network, network,
provider, provider,
providerRequests,
selectedAddress, selectedAddress,
isUnlocked, isUnlocked,
} }

Loading…
Cancel
Save