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 = {
|
static defaultProps = {
|
||||||
icon: null,
|
icon: null,
|
||||||
iconName: 'Unknown External Domain',
|
iconName: '',
|
||||||
headerTitle: '',
|
headerTitle: '',
|
||||||
headerText: '',
|
headerText: '',
|
||||||
}
|
}
|
||||||
|
@ -90,26 +90,22 @@ export default class PermissionConnect extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate (prevProps) {
|
static getDerivedStateFromProps (props, state) {
|
||||||
const {
|
const { permissionsRequest, targetDomainMetadata } = props
|
||||||
permissionsRequest,
|
const { targetDomainMetadata: savedMetadata } = state
|
||||||
lastConnectedInfo,
|
|
||||||
targetDomainMetadata,
|
|
||||||
} = this.props
|
|
||||||
const {
|
|
||||||
redirecting,
|
|
||||||
origin,
|
|
||||||
targetDomainMetadata: savedMetadata,
|
|
||||||
} = this.state
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
permissionsRequest &&
|
permissionsRequest &&
|
||||||
savedMetadata.name !== targetDomainMetadata?.name
|
savedMetadata.name !== targetDomainMetadata?.name
|
||||||
) {
|
) {
|
||||||
this.setState({
|
return { targetDomainMetadata }
|
||||||
targetDomainMetadata,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate (prevProps) {
|
||||||
|
const { permissionsRequest, lastConnectedInfo } = this.props
|
||||||
|
const { redirecting, origin } = this.state
|
||||||
|
|
||||||
if (!permissionsRequest && prevProps.permissionsRequest && !redirecting) {
|
if (!permissionsRequest && prevProps.permissionsRequest && !redirecting) {
|
||||||
|
|
||||||
@ -128,29 +124,29 @@ export default class PermissionConnect extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
redirect (approved) {
|
redirect (approved) {
|
||||||
const { history, hasPendingPermissionsRequests } = this.props
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
redirecting: true,
|
redirecting: true,
|
||||||
permissionsApproved: approved,
|
permissionsApproved: approved,
|
||||||
})
|
})
|
||||||
this.removeBeforeUnload()
|
this.removeBeforeUnload()
|
||||||
|
|
||||||
const doRedirect = () => {
|
|
||||||
if (
|
|
||||||
!hasPendingPermissionsRequests &&
|
|
||||||
getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION
|
|
||||||
) {
|
|
||||||
global.platform.closeCurrentWindow()
|
|
||||||
} else {
|
|
||||||
history.push(DEFAULT_ROUTE)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (approved) {
|
if (approved) {
|
||||||
setTimeout(doRedirect, APPROVE_TIMEOUT)
|
setTimeout(this._doRedirect.bind(this), APPROVE_TIMEOUT)
|
||||||
} else {
|
} 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;
|
position: absolute;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user