2018-07-24 20:40:05 +02:00
|
|
|
import Home from './home.component'
|
|
|
|
import { compose } from 'recompose'
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { withRouter } from 'react-router-dom'
|
2019-03-22 00:03:30 +01:00
|
|
|
import { unconfirmedTransactionsCountSelector } from '../../selectors/confirm-transaction'
|
2019-08-02 05:57:26 +02:00
|
|
|
import { getCurrentEthBalance } from '../../selectors/selectors'
|
2019-08-01 15:24:33 +02:00
|
|
|
import {
|
|
|
|
forceApproveProviderRequestByOrigin,
|
|
|
|
unsetMigratedPrivacyMode,
|
2019-08-02 22:31:26 +02:00
|
|
|
rejectProviderRequestByOrigin,
|
2019-08-01 15:24:33 +02:00
|
|
|
} from '../../store/actions'
|
|
|
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util'
|
|
|
|
import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums'
|
2019-07-12 17:41:39 +02:00
|
|
|
|
2019-08-02 20:59:28 +02:00
|
|
|
const activeTabDappProtocols = ['http:', 'https:', 'dweb:', 'ipfs:', 'ipns:', 'ssb:']
|
|
|
|
|
2018-07-24 20:40:05 +02:00
|
|
|
const mapStateToProps = state => {
|
2019-08-01 15:24:33 +02:00
|
|
|
const { activeTab, metamask, appState } = state
|
2018-07-24 20:40:05 +02:00
|
|
|
const {
|
2019-08-01 15:24:33 +02:00
|
|
|
approvedOrigins,
|
2019-08-02 22:31:26 +02:00
|
|
|
dismissedOrigins,
|
2018-08-28 20:20:30 +02:00
|
|
|
suggestedTokens,
|
2018-09-27 20:19:09 +02:00
|
|
|
providerRequests,
|
2019-08-01 15:24:33 +02:00
|
|
|
migratedPrivacyMode,
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode,
|
|
|
|
} = {},
|
2019-08-02 05:57:26 +02:00
|
|
|
seedPhraseBackedUp,
|
2019-08-02 20:43:15 +02:00
|
|
|
tokens,
|
2018-07-24 20:40:05 +02:00
|
|
|
} = metamask
|
2019-08-02 05:57:26 +02:00
|
|
|
const accountBalance = getCurrentEthBalance(state)
|
2018-07-24 20:40:05 +02:00
|
|
|
const { forgottenPassword } = appState
|
|
|
|
|
2019-08-02 20:59:28 +02:00
|
|
|
const isUnconnected = Boolean(
|
|
|
|
activeTab &&
|
|
|
|
activeTabDappProtocols.includes(activeTab.protocol) &&
|
|
|
|
privacyMode &&
|
2019-08-02 22:31:26 +02:00
|
|
|
!approvedOrigins[activeTab.origin] &&
|
|
|
|
!dismissedOrigins[activeTab.origin]
|
2019-08-02 20:59:28 +02:00
|
|
|
)
|
2019-08-01 15:24:33 +02:00
|
|
|
const isPopup = getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP
|
|
|
|
|
2018-07-24 20:40:05 +02:00
|
|
|
return {
|
|
|
|
forgottenPassword,
|
2018-08-28 20:20:30 +02:00
|
|
|
suggestedTokens,
|
2018-07-31 07:03:20 +02:00
|
|
|
unconfirmedTransactionsCount: unconfirmedTransactionsCountSelector(state),
|
2018-09-27 20:19:09 +02:00
|
|
|
providerRequests,
|
2019-08-01 15:24:33 +02:00
|
|
|
showPrivacyModeNotification: migratedPrivacyMode,
|
|
|
|
activeTab,
|
|
|
|
viewingUnconnectedDapp: isUnconnected && isPopup,
|
2019-08-02 20:43:15 +02:00
|
|
|
shouldShowSeedPhraseReminder: !seedPhraseBackedUp && (parseInt(accountBalance, 16) > 0 || tokens.length > 0),
|
2019-08-02 22:31:26 +02:00
|
|
|
isPopup,
|
2018-07-24 20:40:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 15:24:33 +02:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
unsetMigratedPrivacyMode: () => dispatch(unsetMigratedPrivacyMode()),
|
|
|
|
forceApproveProviderRequestByOrigin: (origin) => dispatch(forceApproveProviderRequestByOrigin(origin)),
|
2019-08-02 22:31:26 +02:00
|
|
|
rejectProviderRequestByOrigin: origin => dispatch(rejectProviderRequestByOrigin(origin)),
|
2019-08-01 15:24:33 +02:00
|
|
|
})
|
|
|
|
|
2018-07-24 20:40:05 +02:00
|
|
|
export default compose(
|
|
|
|
withRouter,
|
2019-08-01 15:24:33 +02:00
|
|
|
connect(mapStateToProps, mapDispatchToProps)
|
2018-07-24 20:40:05 +02:00
|
|
|
)(Home)
|