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.

73 lines
1.6 KiB

  1. /*
  2. `<NotificationContainer>`
  3. =========================
  4. This container connects `<Notification>`s to the Redux store.
  5. */
  6. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7. /*
  8. Imports:
  9. --------
  10. */
  11. // Package imports //
  12. import { connect } from 'react-redux';
  13. // Mastodon imports //
  14. import { makeGetNotification } from '../../../mastodon/selectors';
  15. // Our imports //
  16. import Notification from '.';
  17. import { deleteNotification } from '../../../mastodon/actions/notifications';
  18. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  19. /*
  20. State mapping:
  21. --------------
  22. The `mapStateToProps()` function maps various state properties to the
  23. props of our component. We wrap this in `makeMapStateToProps()` so that
  24. we only have to call `makeGetNotification()` once instead of every
  25. time.
  26. */
  27. const makeMapStateToProps = () => {
  28. const getNotification = makeGetNotification();
  29. const mapStateToProps = (state, props) => ({
  30. notification: getNotification(state, props.notification, props.accountId),
  31. settings: state.get('local_settings'),
  32. });
  33. return mapStateToProps;
  34. };
  35. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  36. /*
  37. Dispatch mapping:
  38. -----------------
  39. The `mapDispatchToProps()` function maps dispatches to our store to the
  40. various props of our component. We only need to provide a dispatch for
  41. deleting notifications.
  42. */
  43. const mapDispatchToProps = dispatch => ({
  44. onDeleteNotification (id) {
  45. dispatch(deleteNotification(id));
  46. },
  47. });
  48. export default connect(makeMapStateToProps, mapDispatchToProps)(Notification);