Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Choose on connect in container #422

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions src/containers/LoginModal/LoginModal.container.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { connect } from 'react-redux'
import { LoginModalProps } from 'decentraland-ui/dist/components/LoginModal/LoginModal'
import {
getError,
isEnabling,
Expand All @@ -10,7 +9,8 @@ import { isEnabled } from '../../modules/translation/selectors'
import {
MapStateProps,
MapDispatch,
MapDispatchProps
MapDispatchProps,
OwnProps
} from './LoginModal.types'
import LoginModal from './LoginModal'

Expand All @@ -20,22 +20,13 @@ const mapState = (state: any): MapStateProps => ({
hasTranslations: isEnabled(state)
})

const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({
onConnect: providerType => dispatch(enableWalletRequest(providerType))
const mapDispatch = (
dispatch: MapDispatch,
ownProps: OwnProps
): MapDispatchProps => ({
onConnect:
ownProps.metadata?.onConnect ??
(providerType => dispatch(enableWalletRequest(providerType)))
})

const mergeProps = (
stateProps: MapStateProps,
dispatchProps: MapDispatchProps,
ownProps: LoginModalProps
): LoginModalProps => ({
...stateProps,
...dispatchProps,
...ownProps
})

export default connect(
mapState,
mapDispatch,
mergeProps
)(LoginModal)
export default connect(mapState, mapDispatch)(LoginModal)
2 changes: 1 addition & 1 deletion src/containers/LoginModal/LoginModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class LoginModal extends React.PureComponent<Props, State> {
}

handleOnConnect = (loginType: LoginModalOptionType) => {
const onConnect = this.props.metadata?.onConnect ?? this.props.onConnect
const { onConnect } = this.props
const providerType: ProviderType = toProviderType(loginType)
onConnect(providerType)
}
Expand Down