The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

90 lines
3.3 KiB

  1. import React from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import StatusContainer from '../../../containers/status_container';
  4. import AccountContainer from '../../../containers/account_container';
  5. import Avatar from '../../../components/avatar';
  6. import { FormattedMessage } from 'react-intl';
  7. import Permalink from '../../../components/permalink';
  8. import emojify from '../../../emoji';
  9. import escapeTextContentForBrowser from 'escape-html';
  10. import ImmutablePureComponent from 'react-immutable-pure-component';
  11. class Notification extends ImmutablePureComponent {
  12. static propTypes = {
  13. notification: ImmutablePropTypes.map.isRequired
  14. };
  15. renderFollow (account, link) {
  16. return (
  17. <div className='notification notification-follow'>
  18. <div className='notification__message'>
  19. <div className='notification__favourite-icon-wrapper'>
  20. <i className='fa fa-fw fa-user-plus' />
  21. </div>
  22. <FormattedMessage id='notification.follow' defaultMessage='{name} followed you' values={{ name: link }} />
  23. </div>
  24. <AccountContainer id={account.get('id')} withNote={false} />
  25. </div>
  26. );
  27. }
  28. renderMention (notification) {
  29. return <StatusContainer id={notification.get('status')} withDismiss />;
  30. }
  31. renderFavourite (notification, link) {
  32. return (
  33. <div className='notification notification-favourite'>
  34. <div className='notification__message'>
  35. <div className='notification__favourite-icon-wrapper'>
  36. <i className='fa fa-fw fa-star star-icon'/>
  37. </div>
  38. <FormattedMessage id='notification.favourite' defaultMessage='{name} favourited your status' values={{ name: link }} />
  39. </div>
  40. <StatusContainer id={notification.get('status')} account={notification.get('account')} muted={true} withDismiss />
  41. </div>
  42. );
  43. }
  44. renderReblog (notification, link) {
  45. return (
  46. <div className='notification notification-reblog'>
  47. <div className='notification__message'>
  48. <div className='notification__favourite-icon-wrapper'>
  49. <i className='fa fa-fw fa-retweet' />
  50. </div>
  51. <FormattedMessage id='notification.reblog' defaultMessage='{name} boosted your status' values={{ name: link }} />
  52. </div>
  53. <StatusContainer id={notification.get('status')} account={notification.get('account')} muted={true} withDismiss />
  54. </div>
  55. );
  56. }
  57. render () { // eslint-disable-line consistent-return
  58. const { notification } = this.props;
  59. const account = notification.get('account');
  60. const displayName = account.get('display_name').length > 0 ? account.get('display_name') : account.get('username');
  61. const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) };
  62. const link = <Permalink className='notification__display-name' href={account.get('url')} title={account.get('acct')} to={`/accounts/${account.get('id')}`} dangerouslySetInnerHTML={displayNameHTML} />;
  63. switch(notification.get('type')) {
  64. case 'follow':
  65. return this.renderFollow(account, link);
  66. case 'mention':
  67. return this.renderMention(notification);
  68. case 'favourite':
  69. return this.renderFavourite(notification, link);
  70. case 'reblog':
  71. return this.renderReblog(notification, link);
  72. }
  73. }
  74. }
  75. export default Notification;