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

28 lines
791 B
JavaScript
Raw Normal View History

2018-03-16 01:29:45 +01:00
const connect = require('react-redux').connect
const t = require('../i18n-helper').getMessage
2018-03-16 01:29:45 +01:00
const metamaskConnect = (mapStateToProps, mapDispatchToProps) => {
return connect(
_higherOrderMapStateToProps(mapStateToProps),
mapDispatchToProps
)
}
const _higherOrderMapStateToProps = (mapStateToProps) => {
2018-03-23 17:51:32 +01:00
let _t
let currentLocale
return (state, ownProps = {}) => {
const stateProps = mapStateToProps
? mapStateToProps(state, ownProps)
: ownProps
2018-03-23 17:51:32 +01:00
if (currentLocale !== state.metamask.currentLocale) {
currentLocale = state.metamask.currentLocale
_t = t.bind(null, state.localeMessages)
}
stateProps.t = _t
2018-03-16 01:29:45 +01:00
return stateProps
}
}
module.exports = metamaskConnect