2017-11-17 19:11:18 -08:00
|
|
|
// Package imports.
|
2017-07-21 11:33:16 -07:00
|
|
|
import { connect } from 'react-redux';
|
2017-11-17 19:11:18 -08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2017-07-21 11:33:16 -07:00
|
|
|
|
2017-11-17 19:11:18 -08:00
|
|
|
// Our imports.
|
2017-12-03 23:26:40 -08:00
|
|
|
import NotificationPurgeButtons from 'flavours/glitch/components/notification_purge_buttons';
|
2017-07-21 11:33:16 -07:00
|
|
|
import {
|
|
|
|
deleteMarkedNotifications,
|
|
|
|
enterNotificationClearingMode,
|
2017-07-30 09:36:28 -07:00
|
|
|
markAllNotifications,
|
2017-12-03 23:26:40 -08:00
|
|
|
} from 'flavours/glitch/actions/notifications';
|
|
|
|
import { openModal } from 'flavours/glitch/actions/modal';
|
2017-07-21 11:33:16 -07:00
|
|
|
|
2017-07-30 09:36:28 -07:00
|
|
|
const messages = defineMessages({
|
|
|
|
clearMessage: { id: 'notifications.marked_clear_confirmation', defaultMessage: 'Are you sure you want to permanently clear all selected notifications?' },
|
|
|
|
clearConfirm: { id: 'notifications.marked_clear', defaultMessage: 'Clear selected notifications' },
|
|
|
|
});
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch, { intl }) => ({
|
2017-07-21 11:33:16 -07:00
|
|
|
onEnterCleaningMode(yes) {
|
|
|
|
dispatch(enterNotificationClearingMode(yes));
|
|
|
|
},
|
|
|
|
|
2017-07-30 09:36:28 -07:00
|
|
|
onDeleteMarked() {
|
|
|
|
dispatch(openModal('CONFIRM', {
|
|
|
|
message: intl.formatMessage(messages.clearMessage),
|
|
|
|
confirm: intl.formatMessage(messages.clearConfirm),
|
|
|
|
onConfirm: () => dispatch(deleteMarkedNotifications()),
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
onMarkAll() {
|
|
|
|
dispatch(markAllNotifications(true));
|
|
|
|
},
|
|
|
|
|
|
|
|
onMarkNone() {
|
|
|
|
dispatch(markAllNotifications(false));
|
|
|
|
},
|
|
|
|
|
|
|
|
onInvert() {
|
|
|
|
dispatch(markAllNotifications(null));
|
2017-07-21 11:33:16 -07:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
2017-07-30 09:36:28 -07:00
|
|
|
markNewForDelete: state.getIn(['notifications', 'markNewForDelete']),
|
2017-07-21 11:33:16 -07:00
|
|
|
});
|
|
|
|
|
2017-07-30 09:36:28 -07:00
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(NotificationPurgeButtons));
|