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.

104 lines
2.8 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. getScrollPosition: PropTypes.func,
  17. updateScrollBottom: PropTypes.func,
  18. };
  19. render () {
  20. const {
  21. hidden,
  22. notification,
  23. onMoveDown,
  24. onMoveUp,
  25. onMention,
  26. getScrollPosition,
  27. updateScrollBottom,
  28. } = this.props;
  29. switch(notification.get('type')) {
  30. case 'follow':
  31. return (
  32. <NotificationFollow
  33. hidden={hidden}
  34. id={notification.get('id')}
  35. account={notification.get('account')}
  36. notification={notification}
  37. onMoveDown={onMoveDown}
  38. onMoveUp={onMoveUp}
  39. onMention={onMention}
  40. />
  41. );
  42. case 'mention':
  43. return (
  44. <StatusContainer
  45. containerId={notification.get('id')}
  46. hidden={hidden}
  47. id={notification.get('status')}
  48. notification={notification}
  49. onMoveDown={onMoveDown}
  50. onMoveUp={onMoveUp}
  51. onMention={onMention}
  52. contextType='notifications'
  53. getScrollPosition={getScrollPosition}
  54. updateScrollBottom={updateScrollBottom}
  55. withDismiss
  56. />
  57. );
  58. case 'favourite':
  59. return (
  60. <StatusContainer
  61. containerId={notification.get('id')}
  62. hidden={hidden}
  63. id={notification.get('status')}
  64. account={notification.get('account')}
  65. prepend='favourite'
  66. muted
  67. notification={notification}
  68. onMoveDown={onMoveDown}
  69. onMoveUp={onMoveUp}
  70. onMention={onMention}
  71. getScrollPosition={getScrollPosition}
  72. updateScrollBottom={updateScrollBottom}
  73. withDismiss
  74. />
  75. );
  76. case 'reblog':
  77. return (
  78. <StatusContainer
  79. containerId={notification.get('id')}
  80. hidden={hidden}
  81. id={notification.get('status')}
  82. account={notification.get('account')}
  83. prepend='reblog'
  84. muted
  85. notification={notification}
  86. onMoveDown={onMoveDown}
  87. onMoveUp={onMoveUp}
  88. onMention={onMention}
  89. getScrollPosition={getScrollPosition}
  90. updateScrollBottom={updateScrollBottom}
  91. withDismiss
  92. />
  93. );
  94. default:
  95. return null;
  96. }
  97. }
  98. }