logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

account_container.js (2196B)


  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  4. import { makeGetAccount } from '../selectors';
  5. import Account from '../components/account';
  6. import {
  7. followAccount,
  8. unfollowAccount,
  9. blockAccount,
  10. unblockAccount,
  11. muteAccount,
  12. unmuteAccount,
  13. } from '../actions/accounts';
  14. import { openModal } from '../actions/modal';
  15. import { initMuteModal } from '../actions/mutes';
  16. import { unfollowModal } from '../initial_state';
  17. const messages = defineMessages({
  18. unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
  19. });
  20. const makeMapStateToProps = () => {
  21. const getAccount = makeGetAccount();
  22. const mapStateToProps = (state, props) => ({
  23. account: getAccount(state, props.id),
  24. });
  25. return mapStateToProps;
  26. };
  27. const mapDispatchToProps = (dispatch, { intl }) => ({
  28. onFollow (account) {
  29. if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
  30. if (unfollowModal) {
  31. dispatch(openModal('CONFIRM', {
  32. message: <FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
  33. confirm: intl.formatMessage(messages.unfollowConfirm),
  34. onConfirm: () => dispatch(unfollowAccount(account.get('id'))),
  35. }));
  36. } else {
  37. dispatch(unfollowAccount(account.get('id')));
  38. }
  39. } else {
  40. dispatch(followAccount(account.get('id')));
  41. }
  42. },
  43. onBlock (account) {
  44. if (account.getIn(['relationship', 'blocking'])) {
  45. dispatch(unblockAccount(account.get('id')));
  46. } else {
  47. dispatch(blockAccount(account.get('id')));
  48. }
  49. },
  50. onMute (account) {
  51. if (account.getIn(['relationship', 'muting'])) {
  52. dispatch(unmuteAccount(account.get('id')));
  53. } else {
  54. dispatch(initMuteModal(account));
  55. }
  56. },
  57. onMuteNotifications (account, notifications) {
  58. dispatch(muteAccount(account.get('id'), notifications));
  59. },
  60. });
  61. export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Account));