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.

84 lines
2.0 KiB

  1. // Package imports //
  2. import React from 'react';
  3. import ImmutablePropTypes from 'react-immutable-proptypes';
  4. import ImmutablePureComponent from 'react-immutable-pure-component';
  5. import PropTypes from 'prop-types';
  6. // Mastodon imports //
  7. // Our imports //
  8. import StatusContainer from '../status/container';
  9. import NotificationFollow from './follow';
  10. export default class Notification extends ImmutablePureComponent {
  11. static propTypes = {
  12. notification: ImmutablePropTypes.map.isRequired,
  13. settings: ImmutablePropTypes.map.isRequired,
  14. onDeleteNotification: PropTypes.func.isRequired,
  15. };
  16. renderFollow (notification) {
  17. return (
  18. <NotificationFollow
  19. id={notification.get('id')}
  20. account={notification.get('account')}
  21. onDeleteNotification={this.props.onDeleteNotification}
  22. />
  23. );
  24. }
  25. renderMention (notification) {
  26. return (
  27. <StatusContainer
  28. id={notification.get('status')}
  29. notificationId={notification.get('id')}
  30. withDismiss
  31. />
  32. );
  33. }
  34. renderFavourite (notification) {
  35. return (
  36. <StatusContainer
  37. id={notification.get('status')}
  38. account={notification.get('account')}
  39. prepend='favourite'
  40. muted
  41. notificationId={notification.get('id')}
  42. withDismiss
  43. />
  44. );
  45. }
  46. renderReblog (notification) {
  47. return (
  48. <StatusContainer
  49. id={notification.get('status')}
  50. account={notification.get('account')}
  51. prepend='reblog'
  52. muted
  53. notificationId={notification.get('id')}
  54. withDismiss
  55. />
  56. );
  57. }
  58. render () {
  59. const { notification } = this.props;
  60. switch(notification.get('type')) {
  61. case 'follow':
  62. return this.renderFollow(notification);
  63. case 'mention':
  64. return this.renderMention(notification);
  65. case 'favourite':
  66. return this.renderFavourite(notification);
  67. case 'reblog':
  68. return this.renderReblog(notification);
  69. }
  70. return null;
  71. }
  72. }