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.

124 lines
3.0 KiB

  1. /*
  2. `<NotificationFollow>`
  3. ======================
  4. This component renders a follow notification.
  5. __Props:__
  6. - __`id` (`PropTypes.number.isRequired`) :__
  7. This is the id of the notification.
  8. - __`onDeleteNotification` (`PropTypes.func.isRequired`) :__
  9. The function to call when a notification should be
  10. dismissed/deleted.
  11. - __`account` (`PropTypes.object.isRequired`) :__
  12. The account associated with the follow notification, ie the account
  13. which followed the user.
  14. - __`intl` (`PropTypes.object.isRequired`) :__
  15. Our internationalization object, inserted by `@injectIntl`.
  16. */
  17. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  18. /*
  19. Imports:
  20. --------
  21. */
  22. // Package imports //
  23. import React from 'react';
  24. import ImmutablePropTypes from 'react-immutable-proptypes';
  25. import PropTypes from 'prop-types';
  26. import { FormattedMessage } from 'react-intl';
  27. import escapeTextContentForBrowser from 'escape-html';
  28. import ImmutablePureComponent from 'react-immutable-pure-component';
  29. // Mastodon imports //
  30. import emojify from '../../../mastodon/emoji';
  31. import Permalink from '../../../mastodon/components/permalink';
  32. import AccountContainer from '../../../mastodon/containers/account_container';
  33. // Our imports //
  34. import NotificationOverlayContainer from '../notification/overlay/container';
  35. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  36. /*
  37. Implementation:
  38. ---------------
  39. */
  40. export default class NotificationFollow extends ImmutablePureComponent {
  41. static propTypes = {
  42. id : PropTypes.number.isRequired,
  43. account : ImmutablePropTypes.map.isRequired,
  44. notification : ImmutablePropTypes.map.isRequired,
  45. };
  46. /*
  47. ### `render()`
  48. This actually renders the component.
  49. */
  50. render () {
  51. const { account, notification } = this.props;
  52. /*
  53. `link` is a container for the account's `displayName`, which links to
  54. the account timeline using a `<Permalink>`.
  55. */
  56. const displayName = account.get('display_name') || account.get('username');
  57. const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) };
  58. const link = (
  59. <Permalink
  60. className='notification__display-name'
  61. href={account.get('url')}
  62. title={account.get('acct')}
  63. to={`/accounts/${account.get('id')}`}
  64. dangerouslySetInnerHTML={displayNameHTML}
  65. />
  66. );
  67. /*
  68. We can now render our component.
  69. */
  70. return (
  71. <div className='notification notification-follow'>
  72. <div className='notification__message'>
  73. <div className='notification__favourite-icon-wrapper'>
  74. <i className='fa fa-fw fa-user-plus' />
  75. </div>
  76. <FormattedMessage
  77. id='notification.follow'
  78. defaultMessage='{name} followed you'
  79. values={{ name: link }}
  80. />
  81. </div>
  82. <AccountContainer id={account.get('id')} withNote={false} />
  83. <NotificationOverlayContainer notification={notification} />
  84. </div>
  85. );
  86. }
  87. }