mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
address review feedback
This commit is contained in:
parent
14a5e77edd
commit
d8e7fb4c42
@ -12,7 +12,7 @@ export default class PermissionsConnectHeader extends Component {
|
||||
|
||||
static defaultProps = {
|
||||
icon: null,
|
||||
iconName: 'Unknown External Domain',
|
||||
iconName: '',
|
||||
headerTitle: '',
|
||||
headerText: '',
|
||||
}
|
||||
|
@ -90,26 +90,22 @@ export default class PermissionConnect extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate (prevProps) {
|
||||
const {
|
||||
permissionsRequest,
|
||||
lastConnectedInfo,
|
||||
targetDomainMetadata,
|
||||
} = this.props
|
||||
const {
|
||||
redirecting,
|
||||
origin,
|
||||
targetDomainMetadata: savedMetadata,
|
||||
} = this.state
|
||||
static getDerivedStateFromProps (props, state) {
|
||||
const { permissionsRequest, targetDomainMetadata } = props
|
||||
const { targetDomainMetadata: savedMetadata } = state
|
||||
|
||||
if (
|
||||
permissionsRequest &&
|
||||
savedMetadata.name !== targetDomainMetadata?.name
|
||||
) {
|
||||
this.setState({
|
||||
targetDomainMetadata,
|
||||
})
|
||||
return { targetDomainMetadata }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
componentDidUpdate (prevProps) {
|
||||
const { permissionsRequest, lastConnectedInfo } = this.props
|
||||
const { redirecting, origin } = this.state
|
||||
|
||||
if (!permissionsRequest && prevProps.permissionsRequest && !redirecting) {
|
||||
|
||||
@ -128,29 +124,29 @@ export default class PermissionConnect extends Component {
|
||||
}
|
||||
|
||||
redirect (approved) {
|
||||
const { history, hasPendingPermissionsRequests } = this.props
|
||||
|
||||
this.setState({
|
||||
redirecting: true,
|
||||
permissionsApproved: approved,
|
||||
})
|
||||
this.removeBeforeUnload()
|
||||
|
||||
const doRedirect = () => {
|
||||
if (
|
||||
!hasPendingPermissionsRequests &&
|
||||
getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION
|
||||
) {
|
||||
global.platform.closeCurrentWindow()
|
||||
} else {
|
||||
history.push(DEFAULT_ROUTE)
|
||||
}
|
||||
}
|
||||
|
||||
if (approved) {
|
||||
setTimeout(doRedirect, APPROVE_TIMEOUT)
|
||||
setTimeout(this._doRedirect.bind(this), APPROVE_TIMEOUT)
|
||||
} else {
|
||||
doRedirect()
|
||||
this._doRedirect()
|
||||
}
|
||||
}
|
||||
|
||||
_doRedirect () {
|
||||
const { history, hasPendingPermissionsRequests } = this.props
|
||||
|
||||
if (
|
||||
!hasPendingPermissionsRequests &&
|
||||
getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION
|
||||
) {
|
||||
global.platform.closeCurrentWindow()
|
||||
} else {
|
||||
history.push(DEFAULT_ROUTE)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,4 +80,4 @@
|
||||
position: absolute;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user