The code powering m.abunchtell.com https://m.abunchtell.com
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

90 wiersze
2.2 KiB

  1. import React from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import PropTypes from 'prop-types';
  4. import InnerHeader from '../../account/components/header';
  5. import ActionBar from '../../account/components/action_bar';
  6. import MissingIndicator from '../../../components/missing_indicator';
  7. import ImmutablePureComponent from 'react-immutable-pure-component';
  8. export default class Header extends ImmutablePureComponent {
  9. static propTypes = {
  10. account: ImmutablePropTypes.map,
  11. onFollow: PropTypes.func.isRequired,
  12. onBlock: PropTypes.func.isRequired,
  13. onMention: PropTypes.func.isRequired,
  14. onReport: PropTypes.func.isRequired,
  15. onMute: PropTypes.func.isRequired,
  16. onBlockDomain: PropTypes.func.isRequired,
  17. onUnblockDomain: PropTypes.func.isRequired,
  18. };
  19. static contextTypes = {
  20. router: PropTypes.object,
  21. };
  22. handleFollow = () => {
  23. this.props.onFollow(this.props.account);
  24. }
  25. handleBlock = () => {
  26. this.props.onBlock(this.props.account);
  27. }
  28. handleMention = () => {
  29. this.props.onMention(this.props.account, this.context.router.history);
  30. }
  31. handleReport = () => {
  32. this.props.onReport(this.props.account);
  33. }
  34. handleMute = () => {
  35. this.props.onMute(this.props.account);
  36. }
  37. handleBlockDomain = () => {
  38. const domain = this.props.account.get('acct').split('@')[1];
  39. if (!domain) return;
  40. this.props.onBlockDomain(domain, this.props.account.get('id'));
  41. }
  42. handleUnblockDomain = () => {
  43. const domain = this.props.account.get('acct').split('@')[1];
  44. if (!domain) return;
  45. this.props.onUnblockDomain(domain, this.props.account.get('id'));
  46. }
  47. render () {
  48. const { account } = this.props;
  49. if (account === null) {
  50. return <MissingIndicator />;
  51. }
  52. return (
  53. <div className='account-timeline__header'>
  54. <InnerHeader
  55. account={account}
  56. onFollow={this.handleFollow}
  57. />
  58. <ActionBar
  59. account={account}
  60. onBlock={this.handleBlock}
  61. onMention={this.handleMention}
  62. onReport={this.handleReport}
  63. onMute={this.handleMute}
  64. onBlockDomain={this.handleBlockDomain}
  65. onUnblockDomain={this.handleUnblockDomain}
  66. />
  67. </div>
  68. );
  69. }
  70. }