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.

38 lines
995 B

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. import React from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import PropTypes from 'prop-types';
  4. export default class DisplayName extends React.PureComponent {
  5. static propTypes = {
  6. account: ImmutablePropTypes.map.isRequired,
  7. others: ImmutablePropTypes.list,
  8. localDomain: PropTypes.string,
  9. };
  10. render () {
  11. const { account, others, localDomain } = this.props;
  12. const displayNameHtml = { __html: account.get('display_name_html') };
  13. let suffix;
  14. if (others && others.size > 1) {
  15. suffix = `+${others.size}`;
  16. } else {
  17. let acct = account.get('acct');
  18. if (acct.indexOf('@') === -1 && localDomain) {
  19. acct = `${acct}@${localDomain}`;
  20. }
  21. suffix = <span className='display-name__account'>@{acct}</span>;
  22. }
  23. return (
  24. <span className='display-name'>
  25. <bdi><strong className='display-name__html' dangerouslySetInnerHTML={displayNameHtml} /></bdi> {suffix}
  26. </span>
  27. );
  28. }
  29. }