logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

notifications_container.js (808B)


  1. import { injectIntl } from 'react-intl';
  2. import { connect } from 'react-redux';
  3. import { NotificationStack } from 'react-notification';
  4. import { dismissAlert } from '../../../actions/alerts';
  5. import { getAlerts } from '../../../selectors';
  6. const mapStateToProps = (state, { intl }) => {
  7. const notifications = getAlerts(state);
  8. notifications.forEach(notification => ['title', 'message'].forEach(key => {
  9. const value = notification[key];
  10. if (typeof value === 'object') {
  11. notification[key] = intl.formatMessage(value);
  12. }
  13. }));
  14. return { notifications };
  15. };
  16. const mapDispatchToProps = (dispatch) => {
  17. return {
  18. onDismiss: alert => {
  19. dispatch(dismissAlert(alert));
  20. },
  21. };
  22. };
  23. export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(NotificationStack));