mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
handle multiple pending permissions requests
This commit is contained in:
parent
8b649ddeb9
commit
51956b2a14
@ -6,9 +6,7 @@ import {
|
||||
ENVIRONMENT_TYPE_FULLSCREEN,
|
||||
ENVIRONMENT_TYPE_NOTIFICATION,
|
||||
} from '../../../../app/scripts/lib/enums'
|
||||
import {
|
||||
DEFAULT_ROUTE,
|
||||
} from '../../helpers/constants/routes'
|
||||
import { DEFAULT_ROUTE } from '../../helpers/constants/routes'
|
||||
import PermissionPageContainer from '../../components/app/permission-page-container'
|
||||
import ChooseAccount from './choose-account'
|
||||
import PermissionsRedirect from './redirect'
|
||||
@ -30,6 +28,7 @@ export default class PermissionConnect extends Component {
|
||||
addressLastConnectedMap: PropTypes.object.isRequired,
|
||||
lastConnectedInfo: PropTypes.object.isRequired,
|
||||
permissionsRequestId: PropTypes.string,
|
||||
hasPermissionsRequests: PropTypes.bool.isRequired,
|
||||
history: PropTypes.object.isRequired,
|
||||
connectPath: PropTypes.string.isRequired,
|
||||
confirmPermissionPath: PropTypes.string.isRequired,
|
||||
@ -138,7 +137,7 @@ export default class PermissionConnect extends Component {
|
||||
}
|
||||
|
||||
redirect (approved) {
|
||||
const { history } = this.props
|
||||
const { history, hasPermissionsRequests } = this.props
|
||||
|
||||
this.setState({
|
||||
redirecting: true,
|
||||
@ -146,16 +145,21 @@ export default class PermissionConnect extends Component {
|
||||
})
|
||||
this.removeBeforeUnload()
|
||||
|
||||
const redirectFunction = getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION
|
||||
? () => window.close()
|
||||
: () => history.push(DEFAULT_ROUTE)
|
||||
const doRedirect = () => {
|
||||
if (
|
||||
!hasPermissionsRequests &&
|
||||
getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION
|
||||
) {
|
||||
global.platform.closeCurrentWindow()
|
||||
} else {
|
||||
history.push(DEFAULT_ROUTE)
|
||||
}
|
||||
}
|
||||
|
||||
if (approved) {
|
||||
setTimeout(async () => {
|
||||
redirectFunction()
|
||||
}, APPROVE_TIMEOUT)
|
||||
setTimeout(doRedirect, APPROVE_TIMEOUT)
|
||||
} else {
|
||||
redirectFunction()
|
||||
doRedirect()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@ const mapStateToProps = (state, ownProps) => {
|
||||
const permissionsRequest = permissionsRequests
|
||||
.find((permissionsRequest) => permissionsRequest.metadata.id === permissionsRequestId)
|
||||
|
||||
const hasPermissionsRequests = permissionsRequests.length > 0
|
||||
|
||||
const { metadata = {} } = permissionsRequest || {}
|
||||
const { origin } = metadata
|
||||
const nativeCurrency = getNativeCurrency(state)
|
||||
@ -62,6 +64,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
permissionsRequest,
|
||||
permissionsRequestId,
|
||||
hasPermissionsRequests,
|
||||
accounts: accountsWithLabels,
|
||||
origin,
|
||||
newAccountNumber: accountsWithLabels.length + 1,
|
||||
|
Loading…
Reference in New Issue
Block a user