1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/ui/app/pages/home/home.container.js

51 lines
1.6 KiB
JavaScript
Raw Normal View History

import Home from './home.component'
import { compose } from 'recompose'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { unconfirmedTransactionsCountSelector } from '../../selectors/confirm-transaction'
import {
forceApproveProviderRequestByOrigin,
unsetMigratedPrivacyMode,
} from '../../store/actions'
import { getEnvironmentType } from '../../../../app/scripts/lib/util'
import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums'
const mapStateToProps = state => {
const { activeTab, metamask, appState } = state
const {
approvedOrigins,
lostAccounts,
2018-08-28 20:20:30 +02:00
suggestedTokens,
2018-09-27 20:19:09 +02:00
providerRequests,
migratedPrivacyMode,
featureFlags: {
privacyMode,
} = {},
} = metamask
const { forgottenPassword } = appState
const isUnconnected = Boolean(activeTab && privacyMode && !approvedOrigins[activeTab.origin])
const isPopup = getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP
return {
lostAccounts,
forgottenPassword,
2018-08-28 20:20:30 +02:00
suggestedTokens,
unconfirmedTransactionsCount: unconfirmedTransactionsCountSelector(state),
2018-09-27 20:19:09 +02:00
providerRequests,
showPrivacyModeNotification: migratedPrivacyMode,
activeTab,
viewingUnconnectedDapp: isUnconnected && isPopup,
}
}
const mapDispatchToProps = (dispatch) => ({
unsetMigratedPrivacyMode: () => dispatch(unsetMigratedPrivacyMode()),
forceApproveProviderRequestByOrigin: (origin) => dispatch(forceApproveProviderRequestByOrigin(origin)),
})
export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps)
)(Home)