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.

33 lines
1.1 KiB

  1. import { openDropdownMenu, closeDropdownMenu } from '../actions/dropdown_menu';
  2. import { fetchRelationships } from 'mastodon/actions/accounts';
  3. import { openModal, closeModal } from '../actions/modal';
  4. import { connect } from 'react-redux';
  5. import DropdownMenu from '../components/dropdown_menu';
  6. import { isUserTouching } from '../is_mobile';
  7. const mapStateToProps = state => ({
  8. dropdownPlacement: state.getIn(['dropdown_menu', 'placement']),
  9. openDropdownId: state.getIn(['dropdown_menu', 'openId']),
  10. openedViaKeyboard: state.getIn(['dropdown_menu', 'keyboard']),
  11. });
  12. const mapDispatchToProps = (dispatch, { status, items, scrollKey }) => ({
  13. onOpen(id, onItemClick, dropdownPlacement, keyboard) {
  14. if (status) {
  15. dispatch(fetchRelationships([status.getIn(['account', 'id'])]));
  16. }
  17. dispatch(isUserTouching() ? openModal('ACTIONS', {
  18. status,
  19. actions: items,
  20. onClick: onItemClick,
  21. }) : openDropdownMenu(id, dropdownPlacement, keyboard, scrollKey));
  22. },
  23. onClose(id) {
  24. dispatch(closeModal('ACTIONS'));
  25. dispatch(closeDropdownMenu(id));
  26. },
  27. });
  28. export default connect(mapStateToProps, mapDispatchToProps)(DropdownMenu);