1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-18 07:23:21 +01:00
metamask-extension/ui/app/pages/routes/routes.container.js

67 lines
1.9 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { compose } from 'redux'
import {
getNetworkIdentifier,
getPreferences,
2020-05-02 21:41:17 +02:00
submittedPendingTransactionsSelector,
} from '../../selectors'
import {
hideSidebar,
lockMetamask,
setCurrentCurrency,
setLastActiveTime,
setMouseUserState,
} from '../../store/actions'
import { pageChanged } from '../../ducks/history/history'
2020-10-06 20:28:38 +02:00
import { prepareToLeaveSwaps } from '../../ducks/swaps/swaps'
import Routes from './routes.component'
2020-11-03 00:41:28 +01:00
function mapStateToProps(state) {
const { appState } = state
const {
sidebar,
alertOpen,
alertMessage,
isLoading,
loadingMessage,
} = appState
const { autoLockTimeLimit = 0 } = getPreferences(state)
return {
sidebar,
alertOpen,
alertMessage,
textDirection: state.metamask.textDirection,
isLoading,
loadingMessage,
isUnlocked: state.metamask.isUnlocked,
submittedPendingTransactions: submittedPendingTransactionsSelector(state),
network: state.metamask.network,
provider: state.metamask.provider,
frequentRpcListDetail: state.metamask.frequentRpcListDetail || [],
currentCurrency: state.metamask.currentCurrency,
isMouseUser: state.appState.isMouseUser,
providerId: getNetworkIdentifier(state),
autoLockTimeLimit,
}
}
2020-11-03 00:41:28 +01:00
function mapDispatchToProps(dispatch) {
return {
lockMetaMask: () => dispatch(lockMetamask(false)),
hideSidebar: () => dispatch(hideSidebar()),
setCurrentCurrencyToUSD: () => dispatch(setCurrentCurrency('usd')),
2020-11-03 00:41:28 +01:00
setMouseUserState: (isMouseUser) =>
dispatch(setMouseUserState(isMouseUser)),
setLastActiveTime: () => dispatch(setLastActiveTime()),
pageChanged: (path) => dispatch(pageChanged(path)),
2020-10-06 20:28:38 +02:00
prepareToLeaveSwaps: () => dispatch(prepareToLeaveSwaps()),
}
}
2020-11-03 00:41:28 +01:00
export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps),
)(Routes)