You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.6 KiB
62 lines
1.6 KiB
4 years ago
|
import { connect } from 'react-redux';
|
||
|
import { compose } from 'redux';
|
||
|
import { withRouter } from 'react-router-dom';
|
||
6 years ago
|
import {
|
||
|
toggleAccountMenu,
|
||
|
showAccountDetail,
|
||
|
lockMetamask,
|
||
|
hideWarning,
|
||
4 years ago
|
} from '../../../store/actions';
|
||
5 years ago
|
import {
|
||
|
getAddressConnectedDomainMap,
|
||
5 years ago
|
getMetaMaskAccountsOrdered,
|
||
|
getMetaMaskKeyrings,
|
||
5 years ago
|
getOriginOfCurrentTab,
|
||
5 years ago
|
getSelectedAddress,
|
||
4 years ago
|
} from '../../../selectors';
|
||
|
import AccountMenu from './account-menu.component';
|
||
6 years ago
|
|
||
5 years ago
|
/**
|
||
|
* The min amount of accounts to show search field
|
||
|
*/
|
||
4 years ago
|
const SHOW_SEARCH_ACCOUNTS_MIN_COUNT = 5;
|
||
5 years ago
|
|
||
4 years ago
|
function mapStateToProps(state) {
|
||
|
const {
|
||
|
metamask: { isAccountMenuOpen },
|
||
4 years ago
|
} = state;
|
||
|
const accounts = getMetaMaskAccountsOrdered(state);
|
||
|
const origin = getOriginOfCurrentTab(state);
|
||
|
const selectedAddress = getSelectedAddress(state);
|
||
5 years ago
|
|
||
6 years ago
|
return {
|
||
|
isAccountMenuOpen,
|
||
5 years ago
|
addressConnectedDomainMap: getAddressConnectedDomainMap(state),
|
||
5 years ago
|
originOfCurrentTab: origin,
|
||
4 years ago
|
selectedAddress,
|
||
5 years ago
|
keyrings: getMetaMaskKeyrings(state),
|
||
5 years ago
|
accounts,
|
||
|
shouldShowAccountsSearch: accounts.length >= SHOW_SEARCH_ACCOUNTS_MIN_COUNT,
|
||
4 years ago
|
};
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
function mapDispatchToProps(dispatch) {
|
||
6 years ago
|
return {
|
||
|
toggleAccountMenu: () => dispatch(toggleAccountMenu()),
|
||
5 years ago
|
showAccountDetail: (address) => {
|
||
4 years ago
|
dispatch(showAccountDetail(address));
|
||
|
dispatch(toggleAccountMenu());
|
||
6 years ago
|
},
|
||
|
lockMetamask: () => {
|
||
4 years ago
|
dispatch(lockMetamask());
|
||
|
dispatch(hideWarning());
|
||
|
dispatch(toggleAccountMenu());
|
||
6 years ago
|
},
|
||
4 years ago
|
};
|
||
6 years ago
|
}
|
||
|
|
||
|
export default compose(
|
||
|
withRouter,
|
||
5 years ago
|
connect(mapStateToProps, mapDispatchToProps),
|
||
4 years ago
|
)(AccountMenu);
|