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.

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