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.

34 lines
1.2 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. isModalOpen: state.get('modal').modalType === 'ACTIONS',
  9. dropdownPlacement: state.getIn(['dropdown_menu', 'placement']),
  10. openDropdownId: state.getIn(['dropdown_menu', 'openId']),
  11. openedViaKeyboard: state.getIn(['dropdown_menu', 'keyboard']),
  12. });
  13. const mapDispatchToProps = (dispatch, { status, items }) => ({
  14. onOpen(id, onItemClick, dropdownPlacement, keyboard) {
  15. if (status) {
  16. dispatch(fetchRelationships([status.getIn(['account', 'id'])]));
  17. }
  18. dispatch(isUserTouching() ? openModal('ACTIONS', {
  19. status,
  20. actions: items,
  21. onClick: onItemClick,
  22. }) : openDropdownMenu(id, dropdownPlacement, keyboard));
  23. },
  24. onClose(id) {
  25. dispatch(closeModal('ACTIONS'));
  26. dispatch(closeDropdownMenu(id));
  27. },
  28. });
  29. export default connect(mapStateToProps, mapDispatchToProps)(DropdownMenu);