2017-11-17 19:11:18 -08:00
|
|
|
// Package imports.
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2017-07-21 11:33:16 -07:00
|
|
|
|
2023-05-28 07:38:10 -07:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2017-11-17 19:11:18 -08:00
|
|
|
// Our imports.
|
2023-05-28 07:38:10 -07:00
|
|
|
import { openModal } from 'flavours/glitch/actions/modal';
|
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';
|
2023-05-28 07:38:10 -07:00
|
|
|
import NotificationPurgeButtons from 'flavours/glitch/components/notification_purge_buttons';
|
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() {
|
2023-05-25 06:42:37 -07:00
|
|
|
dispatch(openModal({
|
|
|
|
modalType: 'CONFIRM',
|
|
|
|
modalProps: {
|
|
|
|
message: intl.formatMessage(messages.clearMessage),
|
|
|
|
confirm: intl.formatMessage(messages.clearConfirm),
|
|
|
|
onConfirm: () => dispatch(deleteMarkedNotifications()),
|
|
|
|
},
|
2017-07-30 09:36:28 -07:00
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
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));
|