logo

mastofe

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

column_settings_container.js (1452B)


  1. import { connect } from 'react-redux';
  2. import { defineMessages, injectIntl } from 'react-intl';
  3. import ColumnSettings from '../components/column_settings';
  4. import { changeSetting } from '../../../actions/settings';
  5. import { clearNotifications } from '../../../actions/notifications';
  6. import { changeAlerts as changePushNotifications } from '../../../actions/push_notifications';
  7. import { openModal } from '../../../actions/modal';
  8. const messages = defineMessages({
  9. clearMessage: { id: 'notifications.clear_confirmation', defaultMessage: 'Are you sure you want to permanently clear all your notifications?' },
  10. clearConfirm: { id: 'notifications.clear', defaultMessage: 'Clear notifications' },
  11. });
  12. const mapStateToProps = state => ({
  13. settings: state.getIn(['settings', 'notifications']),
  14. pushSettings: state.get('push_notifications'),
  15. });
  16. const mapDispatchToProps = (dispatch, { intl }) => ({
  17. onChange (path, checked) {
  18. if (path[0] === 'push') {
  19. dispatch(changePushNotifications(path.slice(1), checked));
  20. } else {
  21. dispatch(changeSetting(['notifications', ...path], checked));
  22. }
  23. },
  24. onClear () {
  25. dispatch(openModal('CONFIRM', {
  26. message: intl.formatMessage(messages.clearMessage),
  27. confirm: intl.formatMessage(messages.clearConfirm),
  28. onConfirm: () => dispatch(clearNotifications()),
  29. }));
  30. },
  31. });
  32. export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ColumnSettings));