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.

93 lines
2.4 KiB

  1. // Package imports.
  2. import React from 'react';
  3. import PropTypes from 'prop-types';
  4. import ImmutablePropTypes from 'react-immutable-proptypes';
  5. import ImmutablePureComponent from 'react-immutable-pure-component';
  6. // Our imports,
  7. import StatusContainer from 'flavours/glitch/containers/status_container';
  8. import NotificationFollow from './follow';
  9. export default class Notification extends ImmutablePureComponent {
  10. static propTypes = {
  11. notification: ImmutablePropTypes.map.isRequired,
  12. hidden: PropTypes.bool,
  13. onMoveUp: PropTypes.func.isRequired,
  14. onMoveDown: PropTypes.func.isRequired,
  15. onMention: PropTypes.func.isRequired,
  16. };
  17. render () {
  18. const {
  19. hidden,
  20. notification,
  21. onMoveDown,
  22. onMoveUp,
  23. onMention,
  24. } = this.props;
  25. switch(notification.get('type')) {
  26. case 'follow':
  27. return (
  28. <NotificationFollow
  29. hidden={hidden}
  30. id={notification.get('id')}
  31. account={notification.get('account')}
  32. notification={notification}
  33. onMoveDown={onMoveDown}
  34. onMoveUp={onMoveUp}
  35. onMention={onMention}
  36. />
  37. );
  38. case 'mention':
  39. return (
  40. <StatusContainer
  41. containerId={notification.get('id')}
  42. hidden={hidden}
  43. id={notification.get('status')}
  44. notification={notification}
  45. onMoveDown={onMoveDown}
  46. onMoveUp={onMoveUp}
  47. onMention={onMention}
  48. withDismiss
  49. />
  50. );
  51. case 'favourite':
  52. return (
  53. <StatusContainer
  54. containerId={notification.get('id')}
  55. hidden={hidden}
  56. id={notification.get('status')}
  57. account={notification.get('account')}
  58. prepend='favourite'
  59. muted
  60. notification={notification}
  61. onMoveDown={onMoveDown}
  62. onMoveUp={onMoveUp}
  63. onMention={onMention}
  64. withDismiss
  65. />
  66. );
  67. case 'reblog':
  68. return (
  69. <StatusContainer
  70. containerId={notification.get('id')}
  71. hidden={hidden}
  72. id={notification.get('status')}
  73. account={notification.get('account')}
  74. prepend='reblog'
  75. muted
  76. notification={notification}
  77. onMoveDown={onMoveDown}
  78. onMoveUp={onMoveUp}
  79. onMention={onMention}
  80. withDismiss
  81. />
  82. );
  83. default:
  84. return null;
  85. }
  86. }
  87. }