2017-11-18 05:11:18 +02:00
|
|
|
// Package imports.
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2017-07-21 21:33:16 +03:00
|
|
|
|
2023-05-28 17:38:10 +03:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2017-11-18 05:11:18 +02:00
|
|
|
// Our imports.
|
2023-05-28 17:38:10 +03:00
|
|
|
import { openModal } from 'flavours/glitch/actions/modal';
|
2017-07-21 21:33:16 +03:00
|
|
|
import {
|
|
|
|
deleteMarkedNotifications,
|
|
|
|
enterNotificationClearingMode,
|
2017-07-30 19:36:28 +03:00
|
|
|
markAllNotifications,
|
2017-12-04 09:26:40 +02:00
|
|
|
} from 'flavours/glitch/actions/notifications';
|
2023-05-28 17:38:10 +03:00
|
|
|
import NotificationPurgeButtons from 'flavours/glitch/components/notification_purge_buttons';
|
2017-07-21 21:33:16 +03:00
|
|
|
|
2017-07-30 19:36:28 +03: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 21:33:16 +03:00
|
|
|
onEnterCleaningMode(yes) {
|
|
|
|
dispatch(enterNotificationClearingMode(yes));
|
|
|
|
},
|
|
|
|
|
2017-07-30 19:36:28 +03:00
|
|
|
onDeleteMarked() {
|
2023-05-25 16:42:37 +03:00
|
|
|
dispatch(openModal({
|
|
|
|
modalType: 'CONFIRM',
|
|
|
|
modalProps: {
|
|
|
|
message: intl.formatMessage(messages.clearMessage),
|
|
|
|
confirm: intl.formatMessage(messages.clearConfirm),
|
|
|
|
onConfirm: () => dispatch(deleteMarkedNotifications()),
|
|
|
|
},
|
2017-07-30 19:36:28 +03:00
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
onMarkAll() {
|
|
|
|
dispatch(markAllNotifications(true));
|
|
|
|
},
|
|
|
|
|
|
|
|
onMarkNone() {
|
|
|
|
dispatch(markAllNotifications(false));
|
|
|
|
},
|
|
|
|
|
|
|
|
onInvert() {
|
|
|
|
dispatch(markAllNotifications(null));
|
2017-07-21 21:33:16 +03:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
2017-07-30 19:36:28 +03:00
|
|
|
markNewForDelete: state.getIn(['notifications', 'markNewForDelete']),
|
2017-07-21 21:33:16 +03:00
|
|
|
});
|
|
|
|
|
2017-07-30 19:36:28 +03:00
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(NotificationPurgeButtons));
|