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 {
|
|
|
|
unsetMigratedPrivacyMode,
|
2019-09-16 19:11:01 +02:00
|
|
|
restoreFromThreeBox,
|
|
|
|
turnThreeBoxSyncingOn,
|
|
|
|
getThreeBoxLastUpdated,
|
|
|
|
setRestoredFromThreeBoxToFalse,
|
2019-08-01 15:24:33 +02:00
|
|
|
} from '../../store/actions'
|
2019-09-16 19:11:01 +02:00
|
|
|
import { setThreeBoxLastUpdated } from '../../ducks/app/app'
|
2019-08-01 15:24:33 +02:00
|
|
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util'
|
|
|
|
import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums'
|
2019-07-12 17:41:39 +02:00
|
|
|
|
2018-07-24 20:40:05 +02:00
|
|
|
const mapStateToProps = state => {
|
2019-08-15 23:07:18 +02:00
|
|
|
const { metamask, appState } = state
|
2018-07-24 20:40:05 +02:00
|
|
|
const {
|
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,
|
2019-08-02 05:57:26 +02:00
|
|
|
seedPhraseBackedUp,
|
2019-08-02 20:43:15 +02:00
|
|
|
tokens,
|
2019-09-16 19:11:01 +02:00
|
|
|
threeBoxSynced,
|
|
|
|
restoredFromThreeBox,
|
|
|
|
selectedAddress,
|
|
|
|
featureFlags,
|
2018-07-24 20:40:05 +02:00
|
|
|
} = metamask
|
2019-08-02 05:57:26 +02:00
|
|
|
const accountBalance = getCurrentEthBalance(state)
|
2019-09-16 19:11:01 +02:00
|
|
|
const { forgottenPassword, threeBoxLastUpdated } = appState
|
2018-07-24 20:40:05 +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,
|
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,
|
2019-09-16 19:11:01 +02:00
|
|
|
threeBoxSynced,
|
|
|
|
restoredFromThreeBox,
|
|
|
|
selectedAddress,
|
|
|
|
threeBoxLastUpdated,
|
|
|
|
threeBoxFeatureFlagIsTrue: featureFlags.threeBox,
|
2018-07-24 20:40:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 15:24:33 +02:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
unsetMigratedPrivacyMode: () => dispatch(unsetMigratedPrivacyMode()),
|
2019-09-16 19:11:01 +02:00
|
|
|
turnThreeBoxSyncingOn: () => dispatch(turnThreeBoxSyncingOn()),
|
|
|
|
setupThreeBox: () => {
|
|
|
|
dispatch(getThreeBoxLastUpdated())
|
|
|
|
.then(lastUpdated => {
|
|
|
|
if (lastUpdated) {
|
|
|
|
dispatch(setThreeBoxLastUpdated(lastUpdated))
|
|
|
|
} else {
|
|
|
|
dispatch(setRestoredFromThreeBoxToFalse())
|
|
|
|
dispatch(turnThreeBoxSyncingOn())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
restoreFromThreeBox: (address) => dispatch(restoreFromThreeBox(address)),
|
|
|
|
setRestoredFromThreeBoxToFalse: () => dispatch(setRestoredFromThreeBoxToFalse()),
|
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)
|