2018-07-24 20:40:05 +02:00
|
|
|
import Home from './home.component'
|
2020-02-24 23:58:26 +01:00
|
|
|
import { compose } from 'redux'
|
2018-07-24 20:40:05 +02:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { withRouter } from 'react-router-dom'
|
2020-04-20 19:21:57 +02:00
|
|
|
import {
|
|
|
|
unconfirmedTransactionsCountSelector,
|
2020-05-21 19:33:48 +02:00
|
|
|
getSelectedToken,
|
2020-04-20 19:21:57 +02:00
|
|
|
getCurrentEthBalance,
|
|
|
|
getFirstPermissionRequest,
|
|
|
|
getTotalUnapprovedCount,
|
2020-05-02 21:41:17 +02:00
|
|
|
} from '../../selectors'
|
|
|
|
|
2019-08-01 15:24:33 +02:00
|
|
|
import {
|
2019-09-16 19:11:01 +02:00
|
|
|
restoreFromThreeBox,
|
|
|
|
turnThreeBoxSyncingOn,
|
|
|
|
getThreeBoxLastUpdated,
|
2019-09-26 09:24:52 +02:00
|
|
|
setShowRestorePromptToFalse,
|
2020-04-22 19:11:36 +02:00
|
|
|
setConnectedStatusPopoverHasBeenShown,
|
2020-05-25 21:01:28 +02:00
|
|
|
setDefaultHomeActiveTabName,
|
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'
|
2020-04-20 19:21:57 +02:00
|
|
|
import {
|
|
|
|
ENVIRONMENT_TYPE_NOTIFICATION,
|
|
|
|
ENVIRONMENT_TYPE_POPUP,
|
|
|
|
} from '../../../../app/scripts/lib/enums'
|
2019-07-12 17:41:39 +02:00
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
const mapStateToProps = (state) => {
|
2020-02-20 16:52:10 +01:00
|
|
|
const { metamask, appState } = state
|
2018-07-24 20:40:05 +02:00
|
|
|
const {
|
2018-08-28 20:20:30 +02:00
|
|
|
suggestedTokens,
|
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,
|
2019-09-26 09:24:52 +02:00
|
|
|
showRestorePrompt,
|
2019-09-16 19:11:01 +02:00
|
|
|
selectedAddress,
|
2020-04-22 19:11:36 +02:00
|
|
|
connectedStatusPopoverHasBeenShown,
|
2020-05-25 21:01:28 +02:00
|
|
|
defaultHomeActiveTabName,
|
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
|
2020-04-20 19:21:57 +02:00
|
|
|
const totalUnapprovedCount = getTotalUnapprovedCount(state)
|
|
|
|
|
|
|
|
const envType = getEnvironmentType()
|
|
|
|
const isPopup = envType === ENVIRONMENT_TYPE_POPUP
|
|
|
|
const isNotification = envType === ENVIRONMENT_TYPE_NOTIFICATION
|
2018-07-24 20:40:05 +02:00
|
|
|
|
2019-12-05 22:05:50 +01:00
|
|
|
const firstPermissionsRequest = getFirstPermissionRequest(state)
|
|
|
|
const firstPermissionsRequestId = (firstPermissionsRequest && firstPermissionsRequest.metadata)
|
|
|
|
? firstPermissionsRequest.metadata.id
|
|
|
|
: null
|
2019-08-01 15:24:33 +02:00
|
|
|
|
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),
|
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,
|
2020-04-20 19:21:57 +02:00
|
|
|
isNotification,
|
2019-09-16 19:11:01 +02:00
|
|
|
threeBoxSynced,
|
2019-09-26 09:24:52 +02:00
|
|
|
showRestorePrompt,
|
2019-09-16 19:11:01 +02:00
|
|
|
selectedAddress,
|
2020-05-21 19:33:48 +02:00
|
|
|
selectedToken: getSelectedToken(state),
|
2019-09-16 19:11:01 +02:00
|
|
|
threeBoxLastUpdated,
|
2019-12-05 22:05:50 +01:00
|
|
|
firstPermissionsRequestId,
|
2020-04-20 19:21:57 +02:00
|
|
|
totalUnapprovedCount,
|
2020-04-22 19:11:36 +02:00
|
|
|
connectedStatusPopoverHasBeenShown,
|
2020-05-25 21:01:28 +02:00
|
|
|
defaultHomeActiveTabName,
|
2018-07-24 20:40:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 15:24:33 +02:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
2019-09-16 19:11:01 +02:00
|
|
|
turnThreeBoxSyncingOn: () => dispatch(turnThreeBoxSyncingOn()),
|
|
|
|
setupThreeBox: () => {
|
|
|
|
dispatch(getThreeBoxLastUpdated())
|
2020-02-15 21:34:12 +01:00
|
|
|
.then((lastUpdated) => {
|
2019-09-16 19:11:01 +02:00
|
|
|
if (lastUpdated) {
|
|
|
|
dispatch(setThreeBoxLastUpdated(lastUpdated))
|
|
|
|
} else {
|
2019-09-26 09:24:52 +02:00
|
|
|
dispatch(setShowRestorePromptToFalse())
|
2019-09-16 19:11:01 +02:00
|
|
|
dispatch(turnThreeBoxSyncingOn())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
restoreFromThreeBox: (address) => dispatch(restoreFromThreeBox(address)),
|
2019-09-26 09:24:52 +02:00
|
|
|
setShowRestorePromptToFalse: () => dispatch(setShowRestorePromptToFalse()),
|
2020-04-22 19:11:36 +02:00
|
|
|
setConnectedStatusPopoverHasBeenShown: () => dispatch(setConnectedStatusPopoverHasBeenShown()),
|
2020-05-25 21:01:28 +02:00
|
|
|
onTabClick: (name) => dispatch(setDefaultHomeActiveTabName(name)),
|
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)
|